Posted By

n19ht on 07/28/11


Tagged

php array a Transformar objeto


Versions (?)

Transformar objeto a array PHP


 / Published in: PHP
 

Esta funciĆ³n permite transformar un objeto a un array.

  1. function object_to_array($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] = object_to_array($val);
  8. }
  9. }
  10. else $new = $mixed;
  11. return $new;
  12. }

Report this snippet  

You need to login to post a comment.