我有以下数组:
Array
(
[0] => Array
(
[type] => foo
)
[1] => Array
(
[type] => bar
)
[2] => Array
(
[type] => bar
)
)
并且需要知道是否存在一个或多个type
哪个值是bar
,而不这样做:
foreach ($arrayOfTypes as $type) {
if ($type['type'] == 'bar')
{
// Stuff here
}
}
(仅用于学习目的)