Skip to content

Instantly share code, notes, and snippets.

@davidChu201
Last active August 4, 2016 17:40
Show Gist options
  • Select an option

  • Save davidChu201/fcefc4ca6de84a2b8fde692ca6ed82e5 to your computer and use it in GitHub Desktop.

Select an option

Save davidChu201/fcefc4ca6de84a2b8fde692ca6ed82e5 to your computer and use it in GitHub Desktop.
usort() Sorts an array using a user-defined comparison function
<?php
function u_sort($a,$b)
{
if ($a==$b) return 0;
return ($a < $b) ? -1 : 1;
}
$data=array("li"=> 3,"jim"=>5,"jack"=>10, "tom" =>"16");
uasort($data,"u_sort");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment