NYCPHP Meetup

NYPHP.org

[nycphp-talk] Bogus or not?

Scott Mattocks scott at crisscott.com
Wed Sep 27 11:40:37 EDT 2006


Jonathan Hendler wrote:
> I filed this "bug"/feature request.
> 
> Arrays don't properly overwrite strings in multi-dimensional arrays.
> PHP folks feel that everything works as it should.
> 
> Any thoughts?
> 
> http://bugs.php.net/bug.php?id=38974

You are not turning the string into an array. You are overwriting the 
character at position 0. "Array" syntax is how you access an individual 
character in a string (a string is basically an array of characters). If 
you want to ensure that you overwrite the string with an array, then 
force the string to be an array first.

php -r '$s = "string"; settype($s, "array"); $s[0] = 3; var_dump($s);'

Summary: I agree, it is not a bug.

-- 
Scott Mattocks
Author of: Pro PHP-GTK
http://www.crisscott.com



More information about the talk mailing list