Skip to content

Instantly share code, notes, and snippets.

@anuislam
Last active January 8, 2018 22:36
Show Gist options
  • Save anuislam/5404065bd168bba48ff7fadd2bce3fec to your computer and use it in GitHub Desktop.
Save anuislam/5404065bd168bba48ff7fadd2bce3fec to your computer and use it in GitHub Desktop.
php sort multidimensional array by value
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