Skip to content

Instantly share code, notes, and snippets.

@mrmascott10
Created June 28, 2022 14:17
Show Gist options
  • Save mrmascott10/1dc1abd6e3adfcf89c1f94dcd12b341d to your computer and use it in GitHub Desktop.
Save mrmascott10/1dc1abd6e3adfcf89c1f94dcd12b341d to your computer and use it in GitHub Desktop.
Sort an associative array in PHP
<?php
// ? Sort smallest first
usort($isochronesArr, function ($item1, $item2) { return $item2['mins'] <=> $item1['mins']; });
// ? Sort largest first
usort($isochronesArr, function ($item1, $item2) { return $item1['mins'] <=> $item2['mins']; });
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment