Re: Empty string accessed as characters turning into array?!

From: Date: Sun, 13 Apr 2003 16:20:36 +0000
Subject: Re: Empty string accessed as characters turning into array?!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143670@lists.php.net to get a copy of this message
On Sun, 13 Apr 2003, Leif K-Brooks wrote: > Try the following script: > <?php > $foo = ''; > $foo{0} = 'b'; > $foo{1} = 'a'; > $foo{2} = 'r'; > print "Test 1:\n"; > print_r($foo); > > $foo = ' '; > $foo{0} = 'b'; > $foo{1} = 'a'; > $foo{2} = 'r'; > print "Test 2:\n"; > print_r($foo) > ?> > > The results of test 1 will be an array of "b","a","r". The > results of > test 2 will be the string "bar". I can see why this might happen with > the deprecated way of accessing string characters with [], but shouldn't > {} always leave it as a string? Interesting. Looks like a bug or undocumented feature. I also think the first test would remain as a string. Regards, Philip

« previous php.general (#143670) next »