Bug #51677 [Opn->Bgs]: Multidimensional array returns non-existing value
Edit report at http://bugs.php.net/bug.php?id=51677&edit=1
ID: 51677
Updated by: rasmus@php.net
Reported by: jasonwyz98 at gmail dot com
Summary: Multidimensional array returns non-existing value
-Status: Open
+Status: Bogus
Type: Bug
Package: Arrays related
Operating System: Ubuntu 9.10
PHP Version: 5.3.2
New Comment:
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'.
Previous Comments:
------------------------------------------------------------------------
[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
Thread (3 messages)