Advertisement
Guest User

Untitled

a guest
Nov 27th, 2018
2,841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1.     /**
  2.      * recursive method to convert all arrays to an object
  3.      *
  4.      * @param mixed $array either an array or a string/integer
  5.      *
  6.      * @return array
  7.      */
  8.     private static function _convertToObject($array) {
  9.         if (is_array($array)) {
  10.             foreach ($array as $key => $value) {
  11.                 $array[$key] = self::_convertToObject($value);
  12.             }
  13.  
  14.             return (object)$array;
  15.         }
  16.  
  17.         return $array;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement