Odd behaviour of non-existent keys?
| From: | Geoff Caplan | Date: | Wed, 25 Aug 2004 12:29:35 +0000 |
| Subject: | Odd behaviour of non-existent keys? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-194673@lists.php.net to get a copy of this message | ||
Hi folks,
Getting a result I don't understand.
Why does the non-existent key in the array below evaluate to the
first char of the array value?
$foo = '' ;
$foo['one']['two'] = 'test-value' ;
// Evaluates to: string(1) "t"
var_dump( $foo['one']['two']['three'] ) ;
// Evaluates to NULL, as expected
var_dump($foo['one']['two']['three']['four'] ) ;
Can anyone enlighten me?
I spotted this because I was getting unexpected results with isset()
used on multi-dimensional arrays.
I'm using the latest version of PHP4 on Debian.
------------------
Geoff Caplan