从对象PHP中检索值

时间:2013-08-05 19:16:53

标签: php object

所以目前我有一个运行

的脚本
$obj = $this->search()->browse()->params($aBrowseParams);

将以下数据返回给$ obj

Phpfox_Search_Browse Object
(
    [_iCnt:Phpfox_Search_Browse:private] => 2


    [_aParams:Phpfox_Search_Browse:private] => Array
        (
            [module_id] => music.song
            [alias] => m
            [field] => song_id
            [table] => phpfox_music_song
            [hide_view] => Array
                (
                    [0] => pending
                    [1] => my
                )

            [service] => music.song.browse
        )

    [_oBrowse:Phpfox_Search_Browse:private] => Music_Service_Song_Browse Object
        (
            [_sTable:protected] => 
        )

    [_sView:Phpfox_Search_Browse:private] => 
    [_aConditions] => Array
        (
            [0] => AND ( (m.title LIKE '%test%') )
            [1] => AND m.view_id = 0 AND m.privacy IN(0)
            [2] => AND m.item_id = 0
        )

)

我试图获得以下值

AND ( (m.title LIKE '%test%') )

现在我尝试使用

将其转换为数组
$arr= (array) $obj;

然后通过指定

简单地获取值
$obj['value']['value'] 

但它不起作用,我应该如何检索该值?

1 个答案:

答案 0 :(得分:1)

怎么样:

$value = $obj->_aConditions[0];

只要_aConditions是对象中的公共数组,这就应该有效。