ArrayToObject.php 624 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /* Version 0.9, 6th April 2003 - Simon Willison ( http://simon.incutio.com/ )
  3. Manual: http://scripts.incutio.com/httpclient/
  4. */
  5. function arrayToObject($e){
  6. if( gettype($e)!='array' ) return;
  7. foreach($e as $k=>$v){
  8. if( gettype($v)=='array' || getType($v)=='object' )
  9. $e[$k]=(object)arrayToObject($v);
  10. }
  11. return (object)$e;
  12. }
  13. function objectToArray($e){
  14. $e=(array)$e;
  15. foreach($e as $k=>$v){
  16. if( gettype($v)=='resource' ) return;
  17. if( gettype($v)=='object' || gettype($v)=='array' )
  18. $e[$k]=(array)objectToArray($v);
  19. }
  20. return $e;
  21. }
  22. ?>