Last active
January 8, 2018 22:36
-
-
Save anuislam/5404065bd168bba48ff7fadd2bce3fec to your computer and use it in GitHub Desktop.
php sort multidimensional array by value
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
function multid_sort($arr, $index) { | |
$b = array(); | |
$c = array(); | |
foreach ($arr as $key => $value) { | |
$b[$key] = $value[$index]; | |
} | |
asort($b); | |
foreach ($b as $key => $value) { | |
$c[] = $arr[$key]; | |
} | |
return $c; | |
} | |
$array = multid_sort($array, 'order'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment