-3

var_dump($ib);给我以下输出:

array (
  'data' => array (
    0 => array ( 
      'id' => '2015469353355_151',
      'from' => array ( 
         'name' => 'Aah',
         'id' => '100000292544713',
      ),
      'message' => 'zzzz',
      'created_time' => '2012-06-08T06:16:41+0000',
      ),
    1 => array (
      'id' => '2015469353355_152',
      'from' => array (
        'name' => 'assaaaa',
        'id' => '100000292544713',
      ),
      'message' => 'zzzz',
      'created_time' => '2012-06-08T06:16:51+0000',
    ),
  ),
  'paging' => array (
    'previous' => 'https://graph.facebook.com/2015469353355/comments?limit=25&value=1&redirect=1&__paging_token=2015469353355_175&access_token=AAAFfJS6rRAABAHKGZCy57ZCrSEdQL2kUIYqZAcNBLkbnKTBxRhhx9CTvnUlq2LcAK1kZBWnV6AH5RpvkmGYRFzvk12kNXLe6OhjjapH5PEIUwv1h2tYl&since=1340009948&__previous=1',
  'next' => 'https://graph.facebook.com/2015469353355/comments?limit=25&value=1&redirect=1&access_token=AAAFfJS6rRAABAHKGZCy57ZCrSEdQL2kUIYqZAcNBLkbnKTBxRhhx9CTvnUlq2LcAK1kZBWnV6AH5RpvkmGYRFzvk12kNXLe6OhjjapH5PEIUwv1h2tYl&until=1340009948&__paging_token=2015469353355_175',
  ),
)

如何检索'next'的值?

4

3 回答 3

5

next您可以通过执行以下操作获得 的值,

echo $ib['paging']['next'];
于 2012-07-01T11:05:27.293 回答
4
$array["paging"]['next']

如果我们假设主数组被分配给变量$array

于 2012-07-01T11:07:08.713 回答
3

因为paging是主数组的索引,它本身也是一个数组。您可以使用它的索引来深入了解并获取您需要的信息。

$ib['paging']会给你 -

paging => array (
  'previous' => '...',
  'next' => '...',
)

然后下一步是深入到您再次返回到next索引的数组中。所以你最终得到的是一个在索引中指定索引的语句。

$ib['paging']['next'];

如果next参数也是一个数组,您甚至可以进一步向下使用另一个索引 -

paging => array (
  'previous' => '...',
  'next' => array(
     'url'=>'https://graph.facebook...'
  ),
)

// this will give us `'https://graph.facebook...'`
echo $ib['paging']['next']['url']; 
于 2012-07-01T11:14:22.830 回答