I'm integrating an API to my website which works with data stored in objects while my code is written using arrays.
I'd like a quick and dirty function to convert an object to an array.
I'm integrating an API to my website which works with data stored in objects while my code is written using arrays.
I'd like a quick and dirty function to convert an object to an array.
Some impovements to the "well-knwon" code
Notice that if the function is member of a class (like above) you must change
__FUNCTION__
to__METHOD__
Here is some code:
You can quickly convert deeply nested objects to associative arrays by relying on the behavior of the JSON encode/decode functions: