Posted By

ishkur on 07/24/08


Tagged

php object array


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

xuanyan
uisluu


Array2object


 / Published in: PHP
 

  1. function array2object(array $array) {
  2. $object = new stdClass();
  3. foreach($array as $key => $value) {
  4. if(is_array($value)) {
  5. $object->$key = array2object($value);
  6. } else {
  7. $object->$key = $value;
  8. }
  9. }
  10. return $object;
  11. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: NeoBlack on July 25, 2008

this is only a copy of this snippet: http://snipplr.com/view/7405/php5--function-array2object/ -.- Be ashamed of yourself!

You need to login to post a comment.