Return to Snippet

Revision: 49612
at July 26, 2011 21:32 by freezy


Initial Code
function arrayToObject($array, $class = 'stdClass') {
    if (!is_array($array)) {
        return $array;
    }

    $object = new $class();
    foreach ($array as $key => $value) {
        $object->$key = self::arrayToObject($value);
    }

    return $object;
}

Initial URL

                                

Initial Description

                                

Initial Title
multidimensional array to multidimensional object

Initial Tags
class, object, array, function

Initial Language
PHP