public static function ensureAssociativeArray($object)
    {
        if (!is_object($object) && !is_array($object)) {
            return $object;
        }
        
        $data = (array)$object;
        foreach ($data as $key => $value) { // convert object to associative array
            $data[$key] = self::ensureAssociativeArray($value);
        }
        
        return $data;
    }
public static function ensureAssociativeArray($object)
    {
        if (!is_object($object) && !is_array($object)) {
            return $object;
        }
        
        $data = (array)$object;
        foreach ($data as $key => $value) { // convert object to associative array
            $data[$key] = self::ensureAssociativeArray($value);
        }
        
        return $data;
    }
public static function ensureAssociativeArray ( $ object ) { if ( ! is_object ( $ object ) && ! is_array ( $ object ) ) { return $ object ; } $ data = ( array ) $ object ; foreach ( $ data as $ key => $ value ) { // convert object to associative array $ data [ $ key ] = self :: ensureAssociativeArray ( $ value ) ; } return $ data ; }
Ensure that the given is array or object is an associative array.
If not, the object will be converted.

@param mixed $object
The array or object to ensure to be an associative array.

@return mixed The associative array or the original object if conversion not succesful.
Ensure that the given is array or object is an associative array . If not the object will be converted .