我死了這個陣列,資料陣列里面有一個數字
^ array:1 [▼
"data" => array:15 [▼
0 => array:15 [▼
"product_name" => "MOBILELEGEND - 86 Diamond"
"category" => "Games"
"brand" => "MOBILE LEGEND"
"type" => "Umum"
"seller_name" => "PT***"
"price" => 19800
"buyer_sku_code" => "ML86"
"buyer_product_status" => true
"seller_product_status" => true
"unlimited_stock" => true
"stock" => 0
"multi" => true
"start_cut_off" => "23:30"
"end_cut_off" => "0:20"
"desc" => "no pelanggan = gabungan antara user_id dan zone_id"
]
1 => array:15 [?]
2 => array:15 [?]
]
]
我怎樣才能foreach數字內的值?我的意思是0,1,2
uj5u.com熱心網友回復:
您需要使用嵌套的 foreach 來回圈您擁有的多維陣列。
$arr例如,讓您的陣列被呼叫
// $arr = [ 'data' => [ ['name' => 'lorem'], ... ]];
foreach ($arr['data'] as $item) {
foreach ($item as $key => $value) {
// Do whatever you need here...
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/430338.html
標籤:拉拉维尔
