'page1','name'=>'pagename1')array('page'=>'page2','name'=>'pagename2 ')array('page'=>'page3','name'=>'pagename3')) Is there a built-in function that returns a new array containing only the "name" key value? So I">
I have an array of arrays with the following structure:
array(array('page' => 'page1', 'name' => 'pagename1') array('page' => 'page2', 'name' => 'pagename2') array('page' => 'page3', 'name' => 'pagename3'))
Is there a built-in function that returns a new array containing only the "name" key value? So I would get:
array('pagename1', 'pagename2', 'pagename3')
Starting in
PHP 5.5
you can usearray_column()
:View actual operation
Why does it have to be a built-in function? No, no, write it yourself.
This is a nice and simple approach compared to others in this thread.
In some cases, if the key is not named, you can do this