ID: 24652
Comment by: Nico dot Laus dot 2001 at gmx dot de
Reported By: tater at potatoe dot com
Status: Feedback
Bug Type: Zend Engine 2 problem
Operating System: OS X 10.2
PHP Version: 5CVS-2003-07-14 (dev)
New Comment:
sorry, I forgot to mention:
I am working with WinXP SP1, newest CVS of PHP5 (this time: 2003-07-15
14:30)
Previous Comments:
------------------------------------------------------------------------
[2003-07-15 18:02:57] [EMAIL PROTECTED]
Nico is your problem as well on OSX or another platform?
------------------------------------------------------------------------
[2003-07-15 12:31:54] Nico dot Laus dot 2001 at gmx dot de
I have the same problem, but a simplier Code to see, what is wrong:
print "<form method=POST><input type=submit name=test[test][1]
value=send></form>";
if (isset($_POST['test'])) {
var_dump($_POST['test']);
print ($_POST['test'][1]);
print ($_POST['test']['1']);
print ($_POST['test'][(string)1]);
}
though this index should be numeric, it isn't and even with trying to
access it by string doesn't work!
-> I can't access this value of the array!
------------------------------------------------------------------------
[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