How can make an array from the values of another array's key?By Hardik Savani | January 21, 2016 | | 909 Viewer | Category : PHP
If you are working on PHP or other PHP framework and you want to create array of another array value. now you can see on following example how can you make array form another multidimensional array key's.
For example you have array like:
$multi = array(
['1'] => array('id'=>1,'name'=>'hardik'),
['2'] => array('id'=>1,'name'=>'vimal'),
['3'] => array('id'=>1,'name'=>'harshad'),
but if you want to this multi-dimensional array just like this way:
$test = array('hardik','vimal','harshad');
so, we can make this type of array from multi-dimensional array using array_column() funtion.
you can use this function easy as under.
$result = array_column($multi, 'name');
- How to create custom helper in Laravel 5?
- Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
- How to create and use Middleware in Laravel 5?
- Laravel 5 - Grayscale Image Generate Example from scratch
- AngularJS - How to create read more/less toggle using Directive?
- PHP MySQL contact us form with validation using Bootstrap
- How to resolve - tokenmismatchexception in verifycsrftoken.php Laravel 5 Ajax ?
- AngularJS - How to Limit String Length using Filter?