我有一個數組,看起來是這樣的:PHP搶多維數組鍵值
Array
(
[100] => Array
(
[room_id] => 100
[name] => Town Center
)
[110] => Array
(
[room_id] => 110
[name] => Coffee Shop
[pin_id] => 7146
[pin_x] => 570
[pin_y] => 150
)
)
我在想,如果有,我能找到一個特定值的鍵的方式,如果「pin_id」價值在那裏。例如:
Array
(
[100] => Array
(
[room_id] => 100
[name] => Town Center
)
[110] => Array <- I want to get this key "110"
(
[room_id] => 110
[name] => Coffee Shop
[pin_id] => 7146 <- Because "pin_id" is here
[pin_x] => 570
[pin_y] => 150
)
)
使用與上一個問題中回答相同的循環,但執行'foreach($ array as $ key => $ arr)'然後'$ key'持有您正在查找的鍵110。 – 2013-03-10 02:08:34
你不是已經發布了這個問題嗎?或者,它基本上添加到您的第一個問題上。而且,你的第一個問題得到了答案嗎?如果是這樣,請在信貸到期時給予貸款。 http://stackoverflow.com/questions/15317879/grab-array-value-if-a-specific-key-is-there-with-php – tptcat 2013-03-10 02:10:47