php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30535 Array union (+) doesn't handle array properly
Submitted: 2004-10-22 21:10 UTC Modified: 2004-10-31 01:00 UTC
Votes:3
Avg. Score:3.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: smadeira at zoominternet dot net Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 4.3.9 OS: Linux 2.4.20-8
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-10-22 21:10 UTC] smadeira at zoominternet dot net
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 )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-23 08:22 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Can't reproduce - your code produces the very expected result (tried all dev versions).
 [2004-10-23 13:08 UTC] smadeira at zoominternet dot net
I don't have the ability to run a Linux snapshot since the account is hosted.  I loaded the code here: http://kidsportsoftware.com/datebug.php so you can see it in action.  You can also run phpinfo from here as:
http://kidsportsoftware.com/phpinfo.php to see how the hosting account is configured.

I tried a Windows snapshot (4.3.10-dev) and it does work properly on Windows.
 [2004-10-23 13:12 UTC] derick@php.net
I bet it's a zend optimizer related problem, you could try to install that on your windows machine and see if the problem occurs then?
 [2004-10-31 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2004-12-23 16:28 UTC] garak at studenti dot it
I experience the same problem, with both PHP 4.3.9 and 4.3.10 and Zend Optimizer 2.5.6 (under Linux)
 [2005-01-29 23:17 UTC] tigr at mail15 dot com
FreeBSD 4.8-STABLE/php4.3.10/Zend Optimizer v2.5.7 (optimization passes 1 through 4 enabled)
The same here.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Nov 19 13:01:26 2018 UTC