On 5 May 2010 20:02, Michael Shadle <mike...@gmail.com> wrote:

> 2010/5/5 Michiel Sikma <mich...@thingmajig.org>:
>
> > By the way, if you're stuck on 5.2.10, you could simply cast the result
> to
> > array:
> >
> > var_dump((array)json_decode('{"_urls": ["a", "b"]}'));
>
> I don't see a "available starting in 5.x.x" notice, so I think it's
> been there for a long time...
>
> http://www.php.net/json_decode
>

You're right, but this is about how 5.2.10 ignores the second parameter and
always returns a class, which appears to be a bug. I'm not sure which other
versions have this same problem, but 5.2.11 has correct behavior, which
seems to suggest they found and fixed it by then. I can't find an entry for
this problem in PHP's bug database, however.

My suggestion to typecast the result of json_decode() should only be
followed if you need an array and are required to work with version 5.2.10.

Michiel

Reply via email to