So, I have this:
$abc = array('a','b','c');
foreach ($abc as $k => &$a) {
echo $a;
if ($k == 1)
$abc[] = 'd';
}
Work's as expected, iterating through the foreach 4 times and giving me:
abcd
But now, when I have this:
$myvar = $this->someModel->return_an_array_as_result(); // returns array([0] => array('a' => 'b'))
foreach ($myvar as $myvar_key => &$mv){
$myvar[] = array('e' => 'f');
var_dump($myvar);
if ($myvar_key == 5) die;
}
The foreach only runs once.
Any thoughts on how foreach works when resetting the internal pointer?