Bug #18103 Updated: Incorrect behavior of multi-dimensional Array

From: Date: Tue, 02 Jul 2002 06:59:54 +0000
Subject: Bug #18103 Updated: Incorrect behavior of multi-dimensional Array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12771@lists.php.net to get a copy of this message
ID: 18103 Updated by: stephung@mosp.net Reported By: stephung@mosp.net Status: Bogus Bug Type: Arrays related Operating System: ALL PHP Version: 4.2.1 New Comment: s/surising/surprising/g :) Previous Comments: ------------------------------------------------------------------------ [2002-07-02 02:57:22] stephung@mosp.net Wow, this is a surising side effect when string position retreival operator is the same as array operator. Is there any way/plan to force [] as array operator and {} as string position opeartor? ------------------------------------------------------------------------ [2002-07-01 23:37:42] alan_k@php.net two at the same time :) ------------------------------------------------------------------------ [2002-07-01 23:36:04] alan_k@php.net it is the correct behaviour since test['foo'] is a string, using an array '[]' on a string returns the character: eg. echo $test['foo'][1]; //will equal 'b' since ['bar'] evalates to 0 (zero) it will replace character 'a' with the first character of "123".. it would be nice to emit warnings on string[] format as string{n} is the advised method of using string position retreival/setting.. ------------------------------------------------------------------------ [2002-07-01 23:35:42] sniper@php.net 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 ------------------------------------------------------------------------ [2002-07-01 23:26:10] stephung@mosp.net The following code: $test['foo'] = "abc"; $test['foo']['bar'] = "123"; echo $test['foo']; // Output "1bc" The output is "1bc". IMO, "abc" would be the only semantically correct output, although "Array" is also acceptable, which means value "abc" is replaced by array( 'bar' => "123"). The actual output "1bc" is definietly not correct. This happens on all versions of PHP. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18103&edit=1

« previous php.bugs (#12771) next »