Sort the elements of the $arr array by keys using a user-defined comparison function in PHP
Description
The following code shows how to sort the elements of the $arr array by keys using a user-defined comparison function.
Example
//from w w w . j a v a2 s . co m
<?php
function my_sort($a,$b){
if ($a==$b)
return 0;
return ($a<$b)?-1:1;
}
$arr=array("a"=>4,"b"=>2,"c"=>8,d=>"6");
uksort($arr,"my_sort");
?>