Skip to content

PHP objects vs. arrays

by chris on June 1st, 2010

Whenever I have to talk between PHP and JavaScript, and especially when it comes to JSON, I have to decide whether I am going to use arrays or objects. JavaScript plays well with both, but PHP doesn’t. json_decode outputs a steaming pile of stdClass instances which lack the simplicity of index accessors. I came up with (or found?) this method to recursively cast an object to an array.

From → php

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS