|
Posted by Chameleon on 12/11/05 12:10
In the code below I merge array $b with each element of array $a.
So array $a must be after:
$a == array(array(1, 2, 6, 7, 8), array(2, 3, 6, 7, 8), array(4, 5, 6,
7, 8));
instead, it seems to overwrite last element of $a with before-last and
we have:
$a == array(array(1, 2, 6, 7, 8), array(2, 3, 6, 7, 8), array(2, 3, 6,
7, 8));
php version: PHP 5.1.0RC1 (cli) (built: Aug 16 2005 13:51:15)
(the windows version)
It is a php bug or a my bug?
I see that var_dump($a); prints the corrent data but when I print
element-element var_dump it prints the before-last element two times and
last element zero times.
----------------------------------------------
<?
$a = array(array(1, 2), array(2, 3), array(4, 5));
$b = array(6, 7, 8);
foreach($a as & $v)
$v = array_merge($v, $b);
var_dump($a);
foreach($a as $v)
var_dump($v);
?>
----------------------------------------------
Navigation:
[Reply to this message]
|