I have a multidimensional array that stores people.
Array (
id93294 => (array (
Name => \"Tom Anderson\",
Birthday => \
Many years later, there is a cleaner, more succinct technique provided from PHP7+ ...the spaceship operator and balanced arrays of "criteria".
Code: (Demo)
uasort($array, function($a, $b) {
return [strtotime($a['Birthday']), $a['Hometown'] !== $a['CurrentLocation'], $a['Name']]
<=>
[strtotime($b['Birthday']), $b['Hometown'] !== $b['CurrentLocation'], $b['Name']];
});
var_export($array);
See the demo link for sample input and the output.
This snippet will sort by:
Note: #2 has !== syntax only because false evaluation are treated as 0 and true evaluations are treated as 1.
If you need to change any of the sorting orders for any of the criteria, just swap the $a and $b at the corresponding elements.