Edit report at http://bugs.php.net/bug.php?id=51677&edit=1
ID: 51677 Comment by: jasonwyz98 at gmail dot com Reported by: jasonwyz98 at gmail dot com Summary: Multidimensional array returns non-existing value Status: Bogus Type: Bug Package: Arrays related Operating System: Ubuntu 9.10 PHP Version: 5.3.2 New Comment: Hi Rasmus You're right, but still this type of auto type conversion isn't very intuitive, especially for non PHP experts coming other languages. This should really be on the change list for future versions of PHP. Thanks for the help Jason Previous Comments: ------------------------------------------------------------------------ [2010-04-28 06:49:08] [email protected] Strings can be addressed as arrays of characters which is what you are doing here. For strings only numeric array indices are used, so 'none' is cast to an integer, which means you are getting index 0, or the first char of the string. Hence the 'j'. ------------------------------------------------------------------------ [2010-04-28 06:33:55] jasonwyz98 at gmail dot com Description: ------------ Hi When trying to access a non-existing value in a multidimensional array, instead of causing a PHP error, a value was returned. Jason Test script: --------------- $a = array ( 'name' => 'jason' ); echo $a[ 'name' ][ 'none' ]; Expected result: ---------------- PHP Error Actual result: -------------- The script returns the string "j". ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51677&edit=1
