Posted By

ishkur on 07/28/08


Tagged

class php object array to


Versions (?)

objArray


 / Published in: PHP
 

  1. class objArray
  2. {
  3. function __construct($data=null, &$node=null)
  4. {
  5. foreach ( $data as $key => $value )
  6. {
  7. if ( is_array($value) )
  8. {
  9. if (! $node )
  10. {
  11. $node =& $this;
  12. }
  13. $node->$key = new stdClass();
  14. self::__construct($value,$node->$key);
  15. } else {
  16. if (! $node )
  17. {
  18. $node =& $this;
  19. }
  20. $node->$key = $value;
  21. }
  22. }
  23. }
  24. }

Report this snippet  

You need to login to post a comment.