Exactly. In javascript terms, that is what you'd expect since: array(1=>'test')
..Isn't a valid array. 2009/3/17 Scott MacVicar <sc...@macvicar.net>: > 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 > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php