You are here: php bug? « PHP Programming Language « IT news, forums, messages
php bug?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация