ID: 24652 Updated by: [EMAIL PROTECTED] Reported By: tater at potatoe dot com -Status: Assigned +Status: Closed Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2003-07-14 (dev) Assigned To: sterling New Comment:
This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2003-07-17 23:07:57] [EMAIL PROTECTED] The OS is irrelevant. This simple script shows that there indeed is a bug: <?php /* This works */ $f = array('7' => 0); var_dump($f); var_dump(array_key_exists(7, $f)); var_dump(array_key_exists('7', $f)); /* This doesn't */ $f = array_flip(array('7')); var_dump($f); var_dump(array_key_exists(7, $f)); var_dump(array_key_exists('7', $f)); ?> Result with PHP 4.3.3RC2-dev: ----------------------------- array(1) { [7]=> int(0) } bool(true) bool(true) array(1) { [7]=> int(0) } bool(true) bool(true) Result with PHP 5.0.0b2-dev: --------------------- array(1) { [7]=> int(0) } bool(true) bool(true) array(1) { ["7"]=> int(0) } bool(false) bool(false) Assigning to Sterling who broke it. :) ------------------------------------------------------------------------ [2003-07-14 16:53:10] tater at potatoe dot com Description: ------------ This is really bug #23935, but that's marked 'Closed' and I am still seeing the problem in the current PHP5 code. It's beyond array_flip(), too, strictly. I first saw this in $_POST with a field named "myfield[1]" - this comes through as $_POST["myfield"]["1"]. Same with array_combine() using array("1") as the key array. Reproduce code: --------------- submit a form with hidden field named 'myfield[1]': <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="hidden" name="myfield[1]" value="1" > <input type="submit"> </form> <?php function testit($a) { static $tick = 1; echo "<li>test ", $tick++, ":\n"; var_dump($a, array_key_exists(key($a), $a), empty($a[1]), empty($a['1'])); } testit(array("1"=>"1")); testit(array_flip(array(1=>"1"))); testit(array_combine(array('1'),array('1'))); if (!empty($_POST['myfield'])) { testit($_POST['myfield']); } ?> Expected result: ---------------- Output for test 2 on PHP 4.3.3RC1 (cli) (built: Jun 20 2003 23:09:34) (DEBUG): array(1) { [1]=> int(1) } bool(true) bool(false) bool(false) Actual result: -------------- Output for test 2 on PHP 5.0.0b2-dev (cli) (built: Jul 14 2003 14:14:54) (DEBUG): array(1) { ["1"]=> int(1) } bool(false) bool(true) bool(true) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24652&edit=1