public static function objectArray($object)
    {
        if (is_object($object)) {
            $reflectionClass = new \ReflectionClass(get_class($object));
            $array = [];
            foreach ($reflectionClass->getProperties() as $property) {
                $property->setAccessible(true);
                $array[$property->getName()] = $property->getValue($object);
                $property->setAccessible(false);
            }

            //If above method failed? try, this one.
            $array = (empty($array)) ? json_decode(json_encode($object), true) : $array;

            return $array;
        }

        return false;
    }
public static function objectArray($object)
    {
        if (is_object($object)) {
            $reflectionClass = new \ReflectionClass(get_class($object));
            $array = [];
            foreach ($reflectionClass->getProperties() as $property) {
                $property->setAccessible(true);
                $array[$property->getName()] = $property->getValue($object);
                $property->setAccessible(false);
            }

            //If above method failed? try, this one.
            $array = (empty($array)) ? json_decode(json_encode($object), true) : $array;

            return $array;
        }

        return false;
    }
public static function objectArray ( $ object ) { if ( is_object ( $ object ) ) { $ reflectionClass = new \ ReflectionClass ( get_class ( $ object ) ) ; $ array = [ ] ; foreach ( $ reflectionClass -> getProperties ( ) as $ property ) { $ property -> setAccessible ( true ) ; $ array [ $ property -> getName ( ) ] = $ property -> getValue ( $ object ) ; $ property -> setAccessible ( false ) ; } //If above method failed? try, this one. $ array = ( empty ( $ array ) ) ? json_decode ( json_encode ( $ object ) , true ) : $ array ; return $ array ; } return false ; }
Convert Objects to arrays.

@param object $object

@since 2.0.0

@return array
Convert Objects to arrays .