獲取特定數據我有一個數組,它看起來像下面PHP - 從數組
array:7 [▼
0 => array:7 [▼
"id" => "62"
"name" => "creativeOption"
"label" => "Other"
"value" => "dfsdfsdfsdf"
"someId" => "14"
]
1 => array:7 [▼
"id" => "60"
"name" => "creativeOption"
"label" => "checkboxSelection"
"value" => "AnimSomething"
"someId" => "14"
]
2 => array:7 [▼
"id" => "61"
"name" => "creativeOption"
"label" => "checkboxSelection"
"value" => "Something"
"someId" => "14"
]
3 => array:7 [▼
"id" => "59"
"name" => "creativeNumber"
"label" => "Something"
"value" => ""
"someId" => "14"
]
4 => array:7 [▼
"id" => "57"
"name" => "creativeNumber"
"label" => "Something"
"value" => "Something 2 Info"
"someId" => "14"
]
]
我感興趣的地方獲得的名稱爲creativeOption值。目前,我有這個
foreach ($array as $data) {
foreach($data as $key => $value) {
if($value == 'creativeOption') {
}
}
}
因此,這使我能夠找到所有creativeOption,但我將如何去獲得他們的價值?
'creativeOption'是值。你想得到什麼? –
@ Mr.Engineer如果($ value ['name'] =='creativeOption'){ –
。只是不,它不會工作。檢查@HalayemAnis回答正確的方法來做到這一點,但即使如此,你不需要第二個foreach。 – devpro