Extract column from associative array

Returns a list of specific column values from associative array.

php
fork add to bundle source
function array_column_extract($array, $column) { $result = array(); foreach ($array as $item) { $result[] = $item[$column]; } return $result; }

usage

load_function('array_column_extract'); $array = [ ['name' => 'Donald', 'geo' => 'USA'], ['name' => 'Mariah', 'geo' => 'UK'] ]; $names = array_column_extract($array, 'name'); print_r($names); // Array // ( // [0] => Donald // [1] => Mariah // )
← how to use this in app?
create log ...inout