我有这个非常困难的数组来迭代。我只想要name
索引的值。我已经尝试了很多,但不知道如何找到它。
Array ( [0] => Array ( [created_time] => DateTime Object
( [date] => 2017-04-01 12:58:25.000000 [timezone_type] => 1 [timezone] =>
+00:00 ) [from] => Array ( [name] => Ghulam Mohe Ud Din [id] =>
1242172779233884 ) [message] => Hi there[id] => 10154774339307663_10154774534942663 ))
以下是我的一些代码练习:
foreach ($getPostlikes as $key=> $item) {//suppose array is $getPostlikes
foreach($item as $i)
{
echo $i['name'];
}
}
任何帮助将不胜感激。谢谢
答案 0 :(得分:1)
数据:
Array (
[0] => Array (
[created_time] => DateTime Object,
(
[date] => 2017-04-01 12:58:25.000000,
[timezone_type] => 1,
[timezone] => +00:00),
[from] => Array ( [name] => Ghulam Mohe Ud Din [id] => 1242172779233884 ),
[message] => Hi there[id] => 10154774339307663_10154774534942663 )
)
这也将消除重复的名称(每个名称只会显示一次)。
$name_list = array();
foreach($postGetLikes as $postno => $post) {
if(!isset($name_list[$post['from']['name']])) {
$name_list[$post['from']['name']] = 0;
}
$name_list[$post['from']['name']]++;
}
foreach($name_list as $name => $count) {
echo $name;
}
答案 1 :(得分:1)
$hash = crypt($entered_password,"");
$hash = md5($hash);