Created
July 5, 2013 14:36
-
-
Save ChristianGaertner/5934969 to your computer and use it in GitHub Desktop.
Simple PHP function to sort an array by it' s collum.
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
function array_sort_by_collum(&$array, $col, $direction = SORT_ASC) | |
{ | |
$sort_col = array(); | |
foreach($array as $key => $row) { | |
$sort_col[$key] = $row[$col]; | |
} | |
array_multisort($sort_col, $direction, $array); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment