Object to Array


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



Copy this code and paste it in your HTML
  1. function object2array($mixed) {
  2. if(is_object($mixed)) $mixed = (array) $mixed;
  3. if(is_array($mixed)) {
  4. $new = array();
  5. foreach($mixed as $key => $val) {
  6. $key = preg_replace("/^\\0(.*)\\0/","",$key);
  7. $new[$key] = object2array($val);
  8. }
  9. }
  10. else $new = $mixed;
  11. return $new;
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.