This code is causing unexpected array content change. What could be the reason of this:
<?php
$arr[] = array('a', 'b');
$arr[] = array('c', 'd');
print_r($arr);
foreach ($arr as &$processed_arr) {
}
foreach ($arr as $processed_arr) {
}
print_r($arr);
Output:
Array
(
[0] => Array
(
[0] => a
[1] => b
)
[1] => Array
(
[0] => c
[1] => d
)
)
Array
(
[0] => Array
(
[0] => a
[1] => b
)
[1] => Array
(
[0] => a
[1] => b
)
)
It can indeed be due to your loop before. foreach
in php leaves the iteration variable in scope even after the loop (Awful, I know).
So code like this:
$loop = [1,2,3];
foreach ($loop as &$c) {}
$c = 4;
var_dump($loop);
Will result in a loop
variable containing [1,2,4]
The rest of your code doesn't look like it could be the cause of this. Of course the implementation of status
is free to do whatever but given the name it seems highly unlikely imo. :)
Next time it might help to post more of the context. It's good to try to trim down the code posted like you have done, but if the posted code no longer exposes the problem (which yours does not) it makes it much harder to guess what's wrong.