Re: Patch and test cases too for
| From: | Lewis Wright | Date: | Wed, 18 Mar 2009 09:20:40 +0000 |
| Subject: | Re: Patch and test cases too for | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-43387@lists.php.net to get a copy of this message | ||
Exactly. In javascript terms, that is what you'd expect since:
array(1=>'test')
..Isn't a valid array.
2009/3/17 Scott MacVicar <scott@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
>
>