Object to Array


/ Published in: PHP
Save to your folder(s)

Converts object to an array


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.