我需要從嵌套在數(shù)組中的值中捕獲變量,但我無(wú)法弄清楚指定該值位置的語(yǔ)法。print_r($result_array) 輸出以下數(shù)組...我想捕捉“這個(gè)值在這里!” 在一個(gè)變量中。$var = $result_array['order'] /// 然后呢???Array( [order] => Array ( [line_items] => Array ( [0] => Array ( [catalog_object_id] => This value here! [quantity] => 1 ) ) [fulfillments] => Array ( [0] => Array ( [state] => PROPOSED [type] => PICKUP [pickup_details] => Array ( [is_curbside_pickup] => 1 [pickup_at] => 2020-05-20 05:09:02 [recipient] => Array ( [display_name] => John ) ) ) ) ))
1 回答

不負(fù)相思意
TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超10個(gè)贊
$var?=?$result_array['order']['line_items'][0]['catalog_object_id']
對(duì)此不應(yīng)有任何混淆。你正在遍歷一個(gè)數(shù)組,所以你只需要在每個(gè)數(shù)組下選擇正確的元素。
- 1 回答
- 0 關(guān)注
- 98 瀏覽
添加回答
舉報(bào)
0/150
提交
取消