title: Variable variables as parameters of custom function in usort()
body: <p>I've been playing around and seeing if I can set up a more dynamic method in PHP.</p>
  <pre><code>usort(
      $dataset,
      function($a, $b){
          return strcasecmp($a[$this-&gt;parameters], $b[$this-&gt;parameters]);
      }
  );
  </code></pre>
  <p>This line would sort array elements in alphabetically descending order. However, if we were to swap variables <code>$a</code> and <code>$b</code> whether in <code>function($a, $b)</code> or <code>($a[$this-&gt;parameters], $b[$this-&gt;parameters])</code> we will get the opposite effect (descending order).</p>
  <p>As I've looked into the matter, there is such a thing as &quot;variable variables&quot; in PHP. An example of this coulde be:</p>
  <pre><code>$a=&quot;hello&quot;;
  $$a=&quot;oops&quot;;
  echo($hello);die;
  </code></pre>
  <p>However, if I similarly try to implement this within the code of line above I get an error.</p>
  <pre><code>$first = 'b';
  $second = 'a';
  usort($dataset, function($$first, $$second){ return strcasecmp($a[$this-&gt;parameters], $b[$this-&gt;parameters]); });
  </code></pre>
  <p>Error:<code>Parse error: syntax error, unexpected '$', expecting variable (T_VARIABLE)</code>.</p>
  <p>The idea is to be able to reverse the effect base on an iff statement result to redefine <code>$first</code> and <code>$second</code> variables. Otherwise one would need to duplicate almost identical code.</p>
  <p>Am I missing something? Maybe some other way to achieve this?</p>