private function traverseObject($obj, $keys)
    {
        if (empty($keys)) {
            return $obj;
        }
        $key = current($keys);

        if (is_array($obj) && isset($obj[$key])) {
            return $this->traverseObject($obj[$key], array_slice($keys, 1));
        } else if (is_object($obj) && isset($obj->{$key})) {
            return $this->traverseObject($obj->{$key}, array_slice($keys, 1));
        } else {
            return null;
        }
    }
private function traverseObject($obj, $keys)
    {
        if (empty($keys)) {
            return $obj;
        }
        $key = current($keys);

        if (is_array($obj) && isset($obj[$key])) {
            return $this->traverseObject($obj[$key], array_slice($keys, 1));
        } else if (is_object($obj) && isset($obj->{$key})) {
            return $this->traverseObject($obj->{$key}, array_slice($keys, 1));
        } else {
            return null;
        }
    }
private function traverseObject ( $ obj , $ keys ) { if ( empty ( $ keys ) ) { return $ obj ; } $ key = current ( $ keys ) ; if ( is_array ( $ obj ) && isset ( $ obj [ $ key ] ) ) { return $ this -> traverseObject ( $ obj [ $ key ] , array_slice ( $ keys , 1 ) ) ; } else if ( is_object ( $ obj ) && isset ( $ obj -> { $ key } ) ) { return $ this -> traverseObject ( $ obj -> { $ key } , array_slice ( $ keys , 1 ) ) ; } else { return null ; } }
Recursive traversing object based on properties from array

@param $obj
@param $keys
@return mixed
Recursive traversing object based on properties from array