【发布时间】:2016-02-19 11:58:20
【问题描述】:
我正在处理来自 Youtube Data API 的响应,但我不知道如何读取数组中的每个值。
Array
(
[0] => youtube#channelListResponse
[1] => "X"
[2] => Array (
[totalResults] => 1
[resultsPerPage] => 1
)
[3] => Array (
[0] => Array
(
[kind] => youtube#channel
[etag] => "XX"
[id] => XXX
)
)
)
当我尝试使用echo $array[3]['id'] 访问[id] 时,它返回Notice: Undefined offset: 3
【问题讨论】:
-
你的意思是如何访问单个值或循环遍历每个值?
-
你想要什么输出?
-
以访问
totalResults为例,您可以:echo $arrayname[2]['totalResults']。 -
返回:
Notice: Undefined offset: 2 -
所以你可以看到它是
$array['pageInfo']['totalResults']