I Just find a bug in PHP when you are reusing variables by references.
This is the example code:
$lines = array( '1' => array( '1A' ), '2' => array( '2A', '2B', '2C' ) ); foreach($lines as &$items){ foreach($items as $key => $value){ if($value=='2B') unset($items[$key]); } } $items = array(); foreach($lines as $key => $items){ print_r($items); }
What this code should do, is to take the $lines array and delete the 2B value, but it doesn’t work like that, and is because it get crash when you use the $items variable in the second foreach and you already used it as a referece variable, even if you clean the $items variable with an empty array as you see in the code.
Just if you change the name or the $items variable in the second foreach it works fine.
https://bugs.php.net/bug.php?id=67608
Últimos comentarios