我有一个看起来像这样的数组:
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 <-- No "pin_id" so I DON'T need this value
)
[110] => Array
(
[room_id] => 110
[name] => Coffee Shop <-- I want to OBTAIN this value
[pin_id] => 7146 <-- Since the "pin_id" key is here
[pin_x] => 570
[pin_y] => 150
)
)
我试过使用foreach,但它对我来说变得很复杂。我对数组还是很陌生,对术语/函数不太熟悉。