Question on Progressive Arrays
Posted: Tue Jul 20, 2010 2:31 pm
Hello Guys, Quick Question.
Ive been trying to build a script/function to loop through an array, and then when its done loop through it again but starting 1 number higher in the array and appending the number/numbers before it to the end of the array. I will try to explain this question in a diagram.
Sample Array
Simple Loop
What i would like is the following
Loop 1:
SampleA
SampleB
SampleC
SampleD
SampleE
Loop 2
SampleB
SampleC
SampleD
SampleE
SampleA
Loop 3
SampleC
SampleD
SampleE
SampleA
SampleB
Loop 4
SampleD
SampleE
SampleA
SampleB
SampleC
Loop 5
SampleE
SampleA
SampleB
SampleC
SampleD
Loop ETC - Would start the process over again
SampleA
SampleB
SampleC
SampleD
SampleE
Again the this would continue to cycle while it looped untill it ran out of loops.. Any suggestions would be greatly appreciated.
Thanks in advanced.
Ive been trying to build a script/function to loop through an array, and then when its done loop through it again but starting 1 number higher in the array and appending the number/numbers before it to the end of the array. I will try to explain this question in a diagram.
Sample Array
Code: Select all
$arrayList = array("SampleA","SampleB","SampleC","SampleD","SampleE");Code: Select all
$loops = 5; // This number is dynamic and changes so function below needs to by dynamic.
for($c=0;$c<$loops;$c++){
for($i=0;$i<count($arrayList);$i++){
print $arrayList[$i] .'<br />';
}
}Loop 1:
SampleA
SampleB
SampleC
SampleD
SampleE
Loop 2
SampleB
SampleC
SampleD
SampleE
SampleA
Loop 3
SampleC
SampleD
SampleE
SampleA
SampleB
Loop 4
SampleD
SampleE
SampleA
SampleB
SampleC
Loop 5
SampleE
SampleA
SampleB
SampleC
SampleD
Loop ETC - Would start the process over again
SampleA
SampleB
SampleC
SampleD
SampleE
Again the this would continue to cycle while it looped untill it ran out of loops.. Any suggestions would be greatly appreciated.
Thanks in advanced.