How can make an array from the values of another array key?

Today now in this tutorial i will show you how we can make an array from the values of another array’s key. When we are working on PHP or other PHP framework on that time we need to create array of another array value. So now here you can see on following example how we can make an array form another multidimensional array key’s.

For example you have array like:

$multi = array(
	  ['1'] => array('id'=>1,'name'=>'shahriar'),
	  ['2'] => array('id'=>1,'name'=>'sagor'),
	  ['3'] => array('id'=>1,'name'=>'joy'),

but if we want to this multi-dimensional array just like this way:

  $test = array('shahriar','sagor','joy');

so, on that time we can make do this type of array from multi-dimensional array by using array_column() function. So we can use this function easy as under.

$result = array_column($multi, 'name');

Read Also : How to count number of files in folder and remove all files in folder in laravel example?

Thanks for read this, I hope it will you. You can also follow us on Facebook.

Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.