访问对象没有foreach

时间:2013-05-07 21:12:10

标签: php zend-framework

       object(Zend_Paginator)#88 (11) {
  ["_cacheEnabled":protected]=>
  bool(true)
  ["_adapter":protected]=>
  object(Zend_Paginator_Adapter_Array)#89 (2) {
    ["_array":protected]=>
    array(150) {
      [0]=>
      array(19) {
        ["location"]=>
        string(15) "New York"
        ["id"]=>
        string(3) "186"
        ["user_id"]=>
        string(1) "2"
        ["date"]=>
        string(10) "1367893034"
        ["attachment"]=>
        string(1) "0"
        ["content"]=>
        string(4) "nhzu"
        ["first_name"]=>
        string(6) "John"
        ["last_name"]=>
        string(6) "Doe"
        ["thumb_id"]=>
        NULL
        ["thumb_user_id"]=>
        NULL
        ["file_name"]=>
        NULL
        ["folder_name"]=>
        NULL
        ["server_key"]=>
        NULL
        ["type"]=>
        NULL
        ["photo_file_name"]=>
        NULL
        ["photo_folder_name"]=>
        NULL
        ["photo_server_key"]=>
        NULL
        ["photo_id"]=>
        NULL
        ["count_total"]=>
        NULL
      }
      [1]=>

如何在没有foreach的情况下访问id的内容,我只需要第一个0?任何想法?

1 个答案:

答案 0 :(得分:2)

$item = $paginator->getItem(1);

请参阅http://framework.zend.com/svn/framework/standard/tags/release-1.12.3/library/Zend/Paginator.php public function getItem函数定义