Created
July 12, 2017 16:15
-
-
Save atbradley/735d138fa22ed5997eb1207802f8b0e0 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* Implement the array_column() function built-in to PHP 5.5+ | |
*/ | |
if (!function_exists('array_column')) { | |
function array_column($inpt, $columnKey, $indexKey = false) | |
{ | |
if ( $indexKey !== false ) { | |
$outp = array_combine( | |
array_map(function($element) use($indexKey){return $element[$indexKey];}, $inpt), | |
array_map(function($element) use($columnKey){return $element[$columnKey];}, $inpt) | |
); | |
} else { | |
$outp = array_map(function($element) use($columnKey){return $element[$columnKey];}, $inpt); | |
} | |
return $outp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment