I'm trying to understand how usort works. So I used this code:
<?php
function usort_cmp($a, $b) {
echo $a . "->" . $b . "<br />\n";
}
$arr = array(1,2,3,4);
usort($arr, "usort_cmp");
?>
Which results in the following output:
2->1
4->2
3->2
4->3
But I can't understand why this output is like it is?
Can someone explain to me why usort outputs this random looking comparison (though not really random cause it is the same every time I run the script).