If you are using PHP 5.5+, you can use array_column() , for example:
$result = array_column($foo, 'type');
If you need an array with numeric indices, use:
$result = array_values(array_column($foo, 'type'));
If you are using a previous version of PHP and cannot upgrade it at this time, you can use the Userland Implementation array_column() function, written by the same author.
Alternatively, you can also use array_map() . This is basically the same as a loop, except that the loop is not shown explicitly.
$result = array_map(function($arr) { return $arr['type']; }, $foo);
source share