1. Extracted from my laravel controller: .. .. $data = json_decode($response, true); return $data; .. .. return view('homepage')->with('homeExclusives', $homeExclusives);這是返回數據的示例,只是一個簡短版本,因為返回的提要非常大,但這會讓您了解它的結構方式。 array(4) { ["success"]=> bool(true) ["status"]=> int(200) ["bundle"]=> array(2) { [0]=> array(631) { ["StreetDirPrefix"]=> string(2) "SW" ["DistanceToStreetComments"]=> NULL } [1]=> array(631) { ["StreetDirPrefix"]=> string(2) "NE" ["DistanceToStreetComments"]=> NULL } }我需要從 [0] 和 [1] 中提取“StreetDirPrefix”值,但我總是收到錯誤消息。有人可以幫忙嗎?
2 回答

江戶川亂折騰
TA貢獻1851條經驗 獲得超5個贊
對于示例中的數據,您可以使用array_column并指定StreetDirPrefix為列鍵。
$res = array_column($array["bundle"], "StreetDirPrefix");
print_r($res);
- 2 回答
- 0 關注
- 128 瀏覽
添加回答
舉報
0/150
提交
取消