你好我想通过我的数组并想要访问变量。但是,如果我申请foreach,它不会显示任何内容。我做错了什么。这是阵列。
Array
(
[22-2] => Array
(
[-L6mhtqkhmnyuMDkKkOX] => Array
(
[receiver_id] => 2
[sender_id] => 22
[sender_name] => Rider One
[text] => i have done my all orders from post man 1
[timestamp] => 04-03-2018 21:00:42
)
[-L6miAxk59-jvAF2K_mA] => Array
(
[receiver_id] => 2
[sender_id] => 22
[sender_name] => Rider One
[text] => Hahaha
[timestamp] => 05-03-2018 01:34:09
)
这就是我在代码中所做的。
$json_data = json_decode($response, true);
print("<pre>".print_r($json_data,true)."</pre>");
foreach ($json_data as $key ) {
echo $key['22-2']['-L6mhtqkhmnyuMDkKkOX']['sender_name'].'<br>';
}
它没有显示发件人姓名。唯一的白色空白页面正在显示