#30535 [NEW]: Array union (+) doesn't handle array properly

From: Date: Fri, 22 Oct 2004 19:10:27 +0000
Subject: #30535 [NEW]: Array union (+) doesn't handle array properly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-67968@lists.php.net to get a copy of this message
From: smadeira at zoominternet dot net Operating system: Linux 2.4.20-8 PHP version: 4.3.9 PHP Bug Type: Arrays related Bug description: Array union (+) doesn't handle array properly Description: ------------ The reproduce code will generate an array dump and should have the "[] => Zero" as the first element in the array. I am running php 4.3.9. configure line is: './configure' '--with-mysql=/usr/local/mysql' '--with-xml' '--with-curl=../../curl/curl-7.1' '--with-apache=../../apache/apache_1.3.31' '--with-openssl' '--with-zlib' '--enable-bcmath' '--enable-calendar' '--enable-dbx' '--enable-ftp' '--with-gd' '--with-mcrypt' '--with-mhash' '--enable-xslt' '--with-xslt-sablot=/usr/local/lib' '--with-expat-dir=/usr/local' '--with-iconv-dir=/usr/local' '--with-pear' '--with-jpeg-dir=/usr/lib' '--with-png-dir=/usr/lib' Reproduce code: --------------- <?php $x = array('01'=>'One','02'=>'Two'); $x = array('' => 'Zero') + $x; print_r($x); ?> Expected result: ---------------- I am expecting this: Array ( [] => Zero [01] => One [02] => Two ) If I run this script: <?php $x = array('01'=>'One','02'=>'Two'); $y = array('' => 'Zero') + $x; print_r($y); ?> I do get the expected result. (Note the use of $y as the union of the two arrays.) Actual result: -------------- Program returns this: Array ( [01] => One [02] => Two [] => Zero ) -- Edit bug report at http://bugs.php.net/?id=30535&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30535&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30535&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30535&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30535&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30535&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30535&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30535&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30535&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30535&r=support Expected behavior: http://bugs.php.net/fix.php?id=30535&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30535&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30535&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30535&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30535&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30535&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30535&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30535&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30535&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30535&r=mysqlcfg

« previous php.bugs (#67968) next »