Last active
December 21, 2015 13:19
-
-
Save milesstewart88/6312144 to your computer and use it in GitHub Desktop.
Sort a multi-dimensional array by a value - Just use the value's keys
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 compare_distance($a,$b) | |
{ | |
if($a["details"]["distance"] == $b["details"]["distance"]) return 0; | |
return ($a["details"]["distance"] > $b["details"]["distance"]) ? 1 : -1; | |
} | |
usort($the_array, 'compare_distance'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment