Skip to content

Instantly share code, notes, and snippets.

@milesstewart88
Last active December 21, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milesstewart88/6312144 to your computer and use it in GitHub Desktop.
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
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