1. Extracted from my laravel controller: .. .. $data = json_decode($response, true); return $data; .. .. return view('homepage')->with('homeExclusives', $homeExclusives);這是返回?cái)?shù)據(jù)的示例,只是一個(gè)簡(jiǎn)短版本,因?yàn)榉祷氐奶嵋浅4?,但這會(huì)讓您了解它的結(jié)構(gòu)方式。 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”值,但我總是收到錯(cuò)誤消息。有人可以幫忙嗎?
2 回答

江戶川亂折騰
TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊
對(duì)于示例中的數(shù)據(jù),您可以使用array_column并指定StreetDirPrefix為列鍵。
$res = array_column($array["bundle"], "StreetDirPrefix");
print_r($res);
- 2 回答
- 0 關(guān)注
- 133 瀏覽
添加回答
舉報(bào)
0/150
提交
取消