Let's say I have a function like this:
function z($zzz){
for($c=0;$c<5;$c++){
$zzz[$c]= 10;
//more and more codes
}
}
I want to write a loop so that
the 1st time the function is executed, argument $array is passed
the 2nd time : argument $array[0] is passed
while the 3rd time : argument $array[1] is passed
.....
and the 12th time : argument $array[0][0] is passed
This is what comes to my mind:
$a = -1;
$b = -1;
$array = array();
while($a<10){
while($b<10){
z($array);
$b++;
$array= &$array[$b];
}
$a++;
$array= &$array[$a];
}
I've tried it but it didn't work..
I would appreciate if someone can provide a solution..
z()is modifying the array but it's not returning anything. Follow @Jack's answer and make it so that the function takes the reference to the array, not its copy and then try again.