I need to be able to loop an array of items and give them a value from another array and I cant quite get my head around it.
My Array
$myarray = array('a','b','c');
Lets say I have a foreach loop and I loop through 6 items in total.
How do I get the following output
item1 = a
item2 = b
item3 = c
item4 = a
item5 = b
item6 = c
My code looks something like this.
$myarray = array('a','b','c');
$items = array(0,1,2,3,4,5,6);
foreach ($items as $item) {
echo $myarray[$item];
}
Online example. http://codepad.viper-7.com/V6P238
I want to of course be able to loop through an infinite amount of times
forloop. Additionally, what have you tried?