title: Sorting array using usort and global variable
body: <p>I'm using usort to sort a multi-dimensional array. It works fine until the key used to sort concatenates a global variable.</p>
  
  <pre><code>var_dump($lang);//OK, outputs 'eng'
  
  function cmp(array $a, array $b) {
      if ($a['name'] &lt; $b['name']) {
          return -1;
      } else if ($a['name'] &gt; $b['name']) {
          return 1;
      } else {
          return 0;
      }
  }
  
  function cmp2(array $a, array $b) {
      global $lang;
      var_dump($lang);//null?
  
      if ($a['name_'.$lang] &lt; $b['name_'.$lang]) {//line: 93
          return -1;
      } else if ($a['name_'.$lang] &gt; $b['name_'.$lang]) {
          return 1;
      } else {
          return 0;
      }
  }
  
  usort($platform['Server'], "cmp");//OK
  usort($platform['Asset'], "cmp2");//Notice (8): Undefined index: name_ [APP\View\Platforms\view.ctp, line 93]
  </code></pre>
  
  <p>How can I concatenate the lang variable inside the function passed to usort?</p>
  
  <p>I'm on PHP 5.3.</p>
  
  <p>Also, would there be a way to unify both these functions into one while passing the key to sort on as a parameter?</p>