Bug #16179 Updated: Multidimensional Arrays works wrong
| From: | mboeren@php.net | Date: | Wed, 20 Mar 2002 10:26:58 +0000 |
| Subject: | Bug #16179 Updated: Multidimensional Arrays works wrong | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-2939@lists.php.net to get a copy of this message | ||
ID: 16179
Updated by: mboeren@php.net
Reported By: andrej@cybernoidz.de
Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows 2002
PHP Version: 4.1.2
New Comment:
You are mixing the number of dimensions in the array... this can lead
to strange things indeed.
What I think happens is this:
In the second assignment, the extra ["entity"] is seen as an index into
the string "DBJ...", and since "entity" evaluates to zero, the first
character of the string is changed. Because a character is expected,
the string "ABrettEntry" is converted to a char, 'A'.
You can see this if you change ["entity"] to [0] (or [1], then it
changes the second character).
It is easily circumvented by changing the first assignment to $property
[ "src" ][ "brett" ][ "filename" ] = "DBJ_20020112.db.php";
Anyway, I don't think this is a bug in multi-dim-arrays, but perhaps
the documentation is not clear? Perhaps this should be reclassified as
a documentation problem?
Cheerio, Marc.
Previous Comments:
------------------------------------------------------------------------
[2002-03-20 05:10:57] andrej@cybernoidz.de
My php-Code:
<?
$property [ "src" ][ "brett" ] = "DBJ_20020112.db.php";
$property [ "src" ][ "brett" ][ "entity" ] =
"ABrettEntry";
// ----------------------------------------
$GLOBALS[ "property" ] = $property;
echo( "AUSGABE1 :::
".$property["src"]["brett"]["entity"]."<BR>" );
echo( "AUSGABE2 ::: ". $property [ "src" ][ "brett"
]."<BR>" );
?>
And the result of this script looks like this:
AUSGABE1 ::: A
AUSGABE2 ::: ABJ_20020112.db.php
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16179&edit=1