Bug #17668 Updated: $array[] = 1 is not the same as $array[$somenullval]] = 1

From: Date: Sun, 09 Jun 2002 19:35:57 +0000
Subject: Bug #17668 Updated: $array[] = 1 is not the same as $array[$somenullval]] = 1
References: 1  Groups: php.bugs php.doc 
Request: Send a blank email to php-bugs+get-9946@lists.php.net to get a copy of this message
ID: 17668 Updated by: mfischer@php.net Reported By: pgl@instinct.org -Status: Open +Status: Closed -Bug Type: Arrays related +Bug Type: Documentation problem Operating System: Win2K, FreeBSD PHP Version: 4.1.2 New Comment: This bug has been fixed in CVS. You can grab a snapshot of the CVS version 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. Thank you for the report, and for helping us make PHP better. Actually I think it's pretty clear Previous Comments: ------------------------------------------------------------------------ [2002-06-09 14:53:11] pgl@instinct.org $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 this bug report at http://bugs.php.net/?id=17668&edit=1

« previous php.bugs (#9946) next »