Created
December 6, 2016 19:42
-
-
Save bramus/282353e43ef35e412bb765fa83463258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// key = value | |
array_reduce($input, function ($carry, $item) { | |
$carry[$item['x']] = $item['y']; | |
return $carry; | |
}, []); | |
// key = value, from array with keys | |
array_reduce(array_keys($input), function($carry, $key) use ($input) { | |
$carry[] = $input[$key]['x']; | |
return $carry; | |
}, []); | |
// extract column (if array_column were to be missing) | |
array_map(function($item) { | |
return $item['role']; | |
}, $input); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment