我有以下設置,我試圖使用數組結構的數組。一旦在數組數組中找到值,我不確定如何獲取鍵值。php如何獲得數組的數組鍵值
$testboat = 'smallest boat';
$allboats = array(40=>array(1=>'big boat',
2=>'bigger boat'
),
30=>array(1=>'little boat',
2=>'tiny boat',
3=>'smallest boat'));
foreach($allboats as $boats){
foreach($boats as $boat){
if($testboat == $boat) {
/*looking to echo the key or value 30; */
}
}
}
'foreach($ boats as $ key => $ boat)'將會是一個開始。 – deceze
謝謝,但我發現這是錯誤的地方開始。 ($ allboats作爲$ key => $ boats)提供了正確的位置。 – DCR