Posted By

gabrielsmith on 01/21/12


Tagged


Versions (?)

Object to Array


 / Published in: PHP
 

Converts object to an array

  1. function objectToArray( $object ) {
  2. if(!is_object($object) && !is_array($object)){
  3. return $object;
  4. }
  5. if(is_object($object)){
  6. $object = get_object_vars( $object );
  7. }
  8. return array_map( 'objectToArray', $object );
  9. }

Report this snippet  

You need to login to post a comment.