Bug #54248 [NEW]: disappearing array key [987]

From: Date: Mon, 14 Mar 2011 14:48:30 +0000
Subject: Bug #54248 [NEW]: disappearing array key [987]
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-159461@lists.php.net to get a copy of this message
From: Operating system: centos 5.5 PHP version: 5.3.5 Package: Output Control Bug Type: Bug Bug description:disappearing array key [987] Description: ------------ the key 987 disappears Test script: --------------- $ceva=array( array('amount'=>9.89), array('amount'=>9.88), array('amount'=>9.87), array('amount'=>9.86), array('amount'=>9.85), array('amount'=>9.84), array('amount'=>9.83), array('amount'=>9.82), array('amount'=>8.86), array('amount'=>8.85), array('amount'=>8.84), ); function print_a($array) { echo "<pre>"; print_r($array); echo "</pre>"; } print_a($ceva); $usable=array(); foreach($ceva as $b){ $x=$b['amount']*100; $usable[$x]=$b['amount']; var_dump($usable[$x]); } var_dump($usable); Expected result: ---------------- <pre>Array ( [0] => Array ( [amount] => 9.89 ) [1] => Array ( [amount] => 9.88 ) [2] => Array ( [amount] => 9.87 ) [3] => Array ( [amount] => 9.86 ) [4] => Array ( [amount] => 9.85 ) [5] => Array ( [amount] => 9.84 ) [6] => Array ( [amount] => 9.83 ) [7] => Array ( [amount] => 9.82 ) [8] => Array ( [amount] => 8.86 ) [9] => Array ( [amount] => 8.85 ) [10] => Array ( [amount] => 8.84 ) ) </pre>float(9.89) float(9.88) float(9.87) float(9.86) float(9.85) float(9.84) float(9.83) float(9.82) float(8.86) float(8.85) float(8.84) array(10) { [989]=> float(9.89) [988]=> float(9.88) [987]=> float(9.87) [986]=> float(9.86) [985]=> float(9.85) [984]=> float(9.84) [983]=> float(9.83) [982]=> float(9.82) [886]=> float(8.86) [885]=> float(8.85) [884]=> float(8.84) } Actual result: -------------- <pre>Array ( [0] => Array ( [amount] => 9.89 ) [1] => Array ( [amount] => 9.88 ) [2] => Array ( [amount] => 9.87 ) [3] => Array ( [amount] => 9.86 ) [4] => Array ( [amount] => 9.85 ) [5] => Array ( [amount] => 9.84 ) [6] => Array ( [amount] => 9.83 ) [7] => Array ( [amount] => 9.82 ) [8] => Array ( [amount] => 8.86 ) [9] => Array ( [amount] => 8.85 ) [10] => Array ( [amount] => 8.84 ) ) </pre>float(9.89) float(9.88) float(9.87) float(9.86) float(9.85) float(9.84) float(9.83) float(9.82) float(8.86) float(8.85) float(8.84) array(10) { [989]=> float(9.89) [988]=> float(9.88) [986]=> float(9.86) [985]=> float(9.85) [984]=> float(9.84) [983]=> float(9.83) [982]=> float(9.82) [886]=> float(8.86) [885]=> float(8.85) [884]=> float(8.84) } -- Edit bug report at http://bugs.php.net/bug.php?id=54248&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54248&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54248&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54248&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54248&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54248&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54248&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54248&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54248&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54248&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54248&r=support Expected behavior: http://bugs.php.net/fix.php?id=54248&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54248&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54248&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54248&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54248&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54248&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54248&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54248&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54248&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54248&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54248&r=mysqlcfg

« previous php.bugs (#159461) next »