Posted By

iTony on 09/07/08


Tagged

object array convertion


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jamesming
atma
vali29


convertion: array to object, object to array


 / Published in: PHP
 

  1. // Funcion de Objeto a Array
  2. function object_to_array($object)
  3. {
  4. if(is_array($object) || is_object($object))
  5. {
  6. $array = array();
  7. foreach($object as $key => $value)
  8. {
  9. $array[$key] = object_to_array($value);
  10. }
  11. return $array;
  12. }
  13. return $object;
  14. }
  15.  
  16. // Funcion de Array a Objeto
  17. function array_to_object($array = array())
  18. {
  19. return (object) $array;
  20. }

Report this snippet  

You need to login to post a comment.