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');
Thanks for read this, I hope it will you. You can also follow us on Facebook.