public static function recursive_get($obj, $path)
    {    
        foreach (explode('|', $path) as $key) {
            if (is_object($obj)) {
                if (isset($obj->$key)) {
                    $obj = $obj->$key;
                } else {
                    return null;
                }
            } elseif (isset($obj[$key])) {
                $obj = $obj[$key];
            } else {
                return null;
            }
        }
        return $obj;
    }
public static function recursive_get($obj, $path)
    {    
        foreach (explode('|', $path) as $key) {
            if (is_object($obj)) {
                if (isset($obj->$key)) {
                    $obj = $obj->$key;
                } else {
                    return null;
                }
            } elseif (isset($obj[$key])) {
                $obj = $obj[$key];
            } else {
                return null;
            }
        }
        return $obj;
    }
public static function recursive_get ( $ obj , $ path ) { foreach ( explode ( '|' , $ path ) as $ key ) { if ( is_object ( $ obj ) ) { if ( isset ( $ obj -> $ key ) ) { $ obj = $ obj -> $ key ; } else { return null ; } } elseif ( isset ( $ obj [ $ key ] ) ) { $ obj = $ obj [ $ key ] ; } else { return null ; } } return $ obj ; }
Handy function to dive into an array or object without knowing what it is
nested keys can be separated by a pipe so it's possible to get a deeper
key with only one call

@access public
@param  mixed $obj   array or object
@param  string $path the key or key-path (foo|bar)
@return mixed        the keys value or null if not found
Handy function to dive into an array or object without knowing what it is nested keys can be separated by a pipe so it s possible to get a deeper key with only one call