Skip to content

Instantly share code, notes, and snippets.

@bitbybit
Last active August 29, 2015 14:22
Show Gist options
  • Save bitbybit/b4ee41acbffda088ccf8 to your computer and use it in GitHub Desktop.
Save bitbybit/b4ee41acbffda088ccf8 to your computer and use it in GitHub Desktop.
Recursive multidimensional array sort
<?php
function recursive_sort($array,$child) {
usort($array,function($a,$b){
return $a['order'] - $b['order'];
});
foreach($array as $key => $value) {
if(isset($value[$child]) && !empty($value[$child]) && is_array($value[$child])) {
$array[$key][$child] = recursive_sort($value[$child],$child);
}
}
return $array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment