[英]How to access a key of this multidimensional array?
我已经将我的facebook post的JSON输出转换为数组,并且要在post中搜索特定的关键字,我必须访问[message]键,因此如何访问以下[0]和[1]键的[message] :
Array
(
[0] => Array
(
[id] => 459037547545408_496947267087769
[from] => Array
(
[category] => Internet/software
[name] => Open Pdf Library
[id] => 459037547545408
)
[message] => No
[privacy] => Array
(
[value] =>
)
[type] => status
[status_type] => mobile_status_update
[created_time] => 2013-12-17T22:55:55+0000
[updated_time] => 2013-12-17T22:55:55+0000
)
[1] => Array
(
[id] => 459037547545408_496947230421106
[from] => Array
(
[category] => Internet/software
[name] => Open Pdf Library
[id] => 459037547545408
)
[message] => Hello star
[privacy] => Array
(
[value] =>
)
[type] => status
[status_type] => mobile_status_update
[created_time] => 2013-12-17T22:55:46+0000
[updated_time] => 2013-12-17T22:55:46+0000
)
)
<?php
echo $array[0]["message"];
echo "<br>";
echo $array[1]["message"];
?>
应该做的工作
假设$ foo是您的完整数组...
$foo[0]['message'];
$foo[1]['message'];
或循环:
foreach ($foo as $bar) {
echo $bar['message'];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.