Posted By

ikimozu on 11/26/09


Tagged

object array


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jmiller


object_to_array


 / Published in: PHP
 

  1. function object_to_array($object){
  2. $new=NULL;
  3. if(is_object($object)){
  4. $object=(array)$object;
  5. }
  6. if(is_array($object)){
  7. $new=array();
  8. foreach($object as $key => $val) {
  9. $key=preg_replace("/^\\0(.*)\\0/","",$key);
  10. $new[$key]=object_to_array($val);
  11. }
  12. }else{
  13. $new=$object;
  14. }
  15. return $new;
  16. }

Report this snippet  

You need to login to post a comment.