ID: 47211 Updated by: [email protected] Reported By: usmanghanee at gmail dot com -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Windows XP (Service Pack 2) PHP Version: 5.3.0alpha3 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php $foo = "some String"; $foo[0] == "s"; and in oyur case the key is casted to int (0) Previous Comments: ------------------------------------------------------------------------ [2009-01-24 20:28:47] usmanghanee at gmail dot com Description: ------------ I don't know exactly how to explain it. Forgive me if I use wrong English. I'll try to be as short as possible. I tried to use two dimensional array and faced a strange problem. Problem Brief: First I defined two dimensional array. Then, I tried to access a third dimension of such array which was not actually defined at all. The result should have been a warning saying something like "Undefined index" but it printed out some value. The value printed was the first letter of the value at 2nd dimension based offset. Initially, I tried different(variety of) alphabetic and alphanumeric values at third level dimension. It kept on printing the first letter of the value as mentioned above. Then, I tried purely numeric values like '0', '1', '2' and so on. This time it behaved differently. It printed out the letter at offset number, provided as third dimension, from the value at 2nd dimension. I tested it with 5.2.8 and 5.3.0Alpha both. The problem also exists in version 5.3.0Alpha. I also tried the command line methods for both versions which resulted out in the same way. Reproduce code: --------------- $arr = array("sub1" => array("sub2" => "SomeString")); /* // I also tried it as the code given in these comments. // It gave the same output. $arr["sub1"] = array(); $arr["sub1"]["sub2"] = "SomeString"; */ echo $arr["sub1"]["sub2"]["sub3"]; Expected result: ---------------- There should have been some warning saying "Undefined index - sub3". Actual result: -------------- The actual result was an "S" printed on the screen, the first letter of the value "SomeString". /* Please Note: ------------ 1) When I provided '0' instead of "sub3" as the third dimension for echo purpose, it printed out "S" which is the letter at offset '0' of the value "SomeString". 2) When I provided '1' instead of "sub3" as the third dimension for echo purpose, it printed out "o" which is the letter at offset '1' of the value "SomeString". 3) When I provided '2' instead of "sub3" as the third dimension for echo purpose, it printed out "m" which is the letter at offset '2' of the value "SomeString". 4) So on. */ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47211&edit=1
