title: PHP's USORT Callback Function Parameters
body: <p>This is a really esoteric question, but I'm genuinely curious. I'm using usort for the first time today in years, and I'm particularly interested in what exactly is going on. Suppose I've got the following array:</p>
  
  <pre><code>$myArray = array(1, 9, 18, 12, 56);
  </code></pre>
  
  <p>I could sort this with usort:</p>
  
  <pre><code>usort($myArray, function($a, $b){
    if ($a == $b) return 0;
    return ($a &lt; $b) ? -1 : 1;
  });
  </code></pre>
  
  <p>I'm not 100% clear about what is going on with the two parameters $a and $b. What are they, and what do they represent. I mean, I could assume that $a represents the current item in the array, but what exactly is this getting compared to? What is $b?</p>
  
  <p>I could increase my array to include strings:</p>
  
  <pre><code>$myArray = array(
    array("Apples", 10),
    array("Oranges", 12),
    array("Strawberries", 3)
  );
  </code></pre>
  
  <p>And run the following:</p>
  
  <pre><code>usort($myArray, function($a, $b){
    return strcmp($a[0], $b[0]);
  });
  </code></pre>
  
  <p>And that would sort my child-arrays alphabetically based upon the [0] index value. But this doesn't offer any clarity about what $a and $b are. I only know that the match the pattern that I'm seeking.</p>
  
  <p>Can somebody offer some clarity about what is actually taking place?</p>