public static function arrayToObject(array $array = [])
    {
        if (!is_array($array)) {
            throw new \Exception('Not an array');
        }

        $object = new \stdClass();
        if (is_array($array) && count($array) > 0) {
            foreach ($array as $name => $value) {
                if (is_array($value)) {
                    $object->{$name} = self::arrayToObject($value);
                } else {
                    $object->{$name} = $value;
                }
            }
        }

        return $object;
    }
public static function arrayToObject(array $array = [])
    {
        if (!is_array($array)) {
            throw new \Exception('Not an array');
        }

        $object = new \stdClass();
        if (is_array($array) && count($array) > 0) {
            foreach ($array as $name => $value) {
                if (is_array($value)) {
                    $object->{$name} = self::arrayToObject($value);
                } else {
                    $object->{$name} = $value;
                }
            }
        }

        return $object;
    }
public static function arrayToObject ( array $ array = [ ] ) { if ( ! is_array ( $ array ) ) { throw new \ Exception ( 'Not an array' ) ; } $ object = new \ stdClass ( ) ; if ( is_array ( $ array ) && count ( $ array ) > 0 ) { foreach ( $ array as $ name => $ value ) { if ( is_array ( $ value ) ) { $ object -> { $ name } = self :: arrayToObject ( $ value ) ; } else { $ object -> { $ name } = $ value ; } } } return $ object ; }
Convert array to the object.

@param array $array PHP array

@throws \Exception

@return object
Convert array to the object .