Bug #17668: $array[] = 1 is not the same as $array[$somenullval]] = 1
| From: | pgl at instinct dot org | Date: | Sun, 09 Jun 2002 18:53:11 +0000 |
| Subject: | Bug #17668: $array[] = 1 is not the same as $array[$somenullval]] = 1 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-9944@lists.php.net to get a copy of this message | ||
From: pgl@instinct.org
Operating system: Win2K, FreeBSD
PHP version: 4.1.2
PHP Bug Type: Arrays related
Bug description: $array[] = 1 is not the same as $array[$somenullval]] = 1
$array[] = 1 is not the same as $array[$somenullvalue] = 1. This is not
intuitive and undocumented as far as I can tell.
Example:
--8<--
[armadillo:pgl]:~/public_html/test $ cat test.php
<?
#!/usr/local/bin/php -q
$array[] = 1;
$array[] = 2;
print_r($array);
unset($array);
$null = '';
$array[$null] = 3;
$array[$null] = 4;
print_r($array);
?>
--8<--
Prints:
--8<--
Array
(
[0] => 1
[1] => 2
)
Array
(
[] => 4
)
--8<--
I would say this is a documentation problem, but I can't see how this
behaviour could be useful.
regards,
Peter Lowe.
--
Edit bug report at http://bugs.php.net/?id=17668&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17668&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17668&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17668&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17668&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17668&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17668&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17668&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17668&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17668&r=globals