我将laravel应用程序与firebase连接起来,并成功获得以下响应:
array:1 [▼
"-KvJja_r0beLtdoRc29f" => array:5 [▼
"accepted" => "true"
"date" => "1/10/2017"
"hour" => "0:43"
"numberOfPeople" => ""
"tableInfo" => ""
]
]
我想知道如何获得价值" -KvJja_r0beLtdoRc29f"从这个回应。我尝试使用foreach循环,但我得到的内部数据不是关键。
我试过
@foreach($reservations as $reservation)
然后打印结果,但我得到了
"accepted" => "true"
"date" => "1/10/2017"
"hour" => "0:43"
"numberOfPeople" => ""
"tableInfo" => ""
我该怎么做?
答案 0 :(得分:5)
使用可以使用$key
内的foreach()
来获取键值。如下所示: -
@foreach($reservations as $key=> $reservation)
echo $key; // output -KvJja_r0beLtdoRc29f
示例输出: - https://eval.in/937628