On 11 Mar 2009, at 19:25, Christopher Östlund wrote:

I think this behavior is a bit odd too:

php -r "echo json_encode(array(0=>'test'));" // ["test"]
php -r "echo json_encode(array(1=>'test'));" // {"1":"test"}



The reason for this is encoding looks to see if the array is sequentially numbered from 0 to x, and if so its a compatible javascript array. If it starts at any other value or skips a number then it creates an object for its output.

Scott
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to