Bug #68282 [NEW]: Array resulting from array_diff starts at wrong index

From: Date: Wed, 22 Oct 2014 06:15:17 +0000
Subject: Bug #68282 [NEW]: Array resulting from array_diff starts at wrong index
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188251@lists.php.net to get a copy of this message
From: david dot lin dot au at gmail dot com Operating system: PHP version: 5.4.34 Package: Arrays related Bug Type: Bug Bug description:Array resulting from array_diff starts at wrong index Description: ------------ Adding elements to array resulting from array_diff is allocated with wrong numeric index key. Test script: --------------- <?php $a1 = array( 'one', 'two', 'three', 'four' ); $a2 = array_diff( $a1, array( 'one', 'two', 'three', 'four' ) ); $a3 = $a2; $a3[] = 'five'; print_r($a3); Expected result: ---------------- Array ( [0] => five ) Actual result: -------------- Output for PHP 4.3.0 - 5.4.32, 5.5.0 - 5.5.16, 5.6.0, php7@20140507 - 20140521, php7@20140801, hhvm-3.0.1 - 3.3.0 : Array ( [0] => five ) Output for PHP 5.4.34, 5.5.18, 5.6.1 - 5.6.2, php7@20140701, php7@20140901 - 20141001 : Array ( [4] => five ) -- Edit bug report at https://bugs.php.net/bug.php?id=68282&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68282&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68282&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68282&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68282&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68282&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68282&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68282&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68282&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68282&r=support Expected behavior: https://bugs.php.net/fix.php?id=68282&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68282&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68282&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68282&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68282&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68282&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68282&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68282&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68282&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68282&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68282&r=mysqlcfg

« previous php.bugs (#188251) next »