Php 显示json解码数组中的文本
这是调用twitterapi得到的典型结果,但我只想显示其中的id和文本。我已经使用json_decode方法对传入的json结果进行了解码 我从来没有使用过json字符串,如果有人能帮忙,那就太好了Php 显示json解码数组中的文本,php,json,api,rest,twitter,Php,Json,Api,Rest,Twitter,这是调用twitterapi得到的典型结果,但我只想显示其中的id和文本。我已经使用json_decode方法对传入的json结果进行了解码 我从来没有使用过json字符串,如果有人能帮忙,那就太好了 请帮助$yourArray['statuses'][0]['id']和$yourArray['statuses'][0]['text']应该可以做到这一点。嘿,谢谢它起作用了,但是如果我想显示用户数组中的文本,就像我想显示用户id一样,那该怎么办?这些都是嵌套数组。试着理解这个结构,并尽可能深入地
请帮助
$yourArray['statuses'][0]['id']
和$yourArray['statuses'][0]['text']
应该可以做到这一点。嘿,谢谢它起作用了,但是如果我想显示用户数组中的文本,就像我想显示用户id一样,那该怎么办?这些都是嵌套数组。试着理解这个结构,并尽可能深入地理解它。用户
数组也是$yourArray['statuses'][0]
的一项。因此,如果您想从用户数组中访问id
,则需要更深一层:$yourray['statuses'][0]['user']['id']
Array
(
[statuses] => Array
(
[0] => Array
(
[metadata] => Array
(
[result_type] => recent
[iso_language_code] => en
)
[created_at] => Thu Jul 03 08:06:24 +0000 2014
[id] => 484609084809687043
[id_str] => 484609084809687043
[text] => RT @RashtrapatiBhvn: #Rains at the #RashtrapatiBhavan http://t.co/w1imlVFbHe
[source] => Twitter Web Client
[truncated] =>
[in_reply_to_status_id] =>
[in_reply_to_status_id_str] =>
[in_reply_to_user_id] =>
[in_reply_to_user_id_str] =>
[in_reply_to_screen_name] =>
[user] => Array
(
[id] => 1620882618
[id_str] => 1620882618
[name] => HinduNationalist#HDL
[screen_name] => hinduwarrior15
[location] => HINDUSTAN
[description] => I want India to become a exclusive Hindurashtra. Want a HINDUSTAN by hindus for hindus and to hindus. HINDU NATIONALIST.. #HDL
[url] => http://t.co/hWAAfdlWMX
[entities] => Array
(
[url] => Array
(
[urls] => Array
(
[0] => Array
(
[url] => http://t.co/hWAAfdlWMX
[expanded_url] => http://www.hdlindia.org/
[display_url] => hdlindia.org
[indices] => Array
(
[0] => 0
[1] => 22
)
)
)
)