modify array in loop
- by SpawnCxy
Here is the code:
$arraya = array('a','b','c');
foreach($arraya as $key=>$value)
{
if($value == 'b')
{
$arraya[] = 'd';
//print_r($arraya); //$arraya now becomes array('a','b','c','d')
}
echo $key.' is '.$value."\n";
}
and it will get:
0 is a
1 is b
2 is c
And I wonder why 3 is d doesn't show up??