title: PHP sort array by key names
body: <p>I have an array like this </p>
  
  <pre><code>//$src
  Array(
  [dim_55] =&gt; path/to/image.jpg
  [dim_180] =&gt; path/to/image.jpg
  [dim_190] =&gt; path/to/image.jpg
  [dim_475] =&gt; path/to/image.jpg
  [dim_635] =&gt; path/to/image.jpg
  [dim_540] =&gt; path/to/image.jpg
  [dim_1130] =&gt; path/to/image.jpg
  [dim_1900] =&gt; path/to/image.jpg
  )
  </code></pre>
  
  <p>( <code>path/to/image.jpg</code> is a generic path )</p>
  
  <p>I would like to order this by <code>key</code> in an order like</p>
  
  <pre><code>dim_1900
  dim_1130
  dim_635
  dim_540
  dim_475
  ..
  </code></pre>
  
  <p>To achieve this solution I did something like:</p>
  
  <pre><code>$sortSrc = array();
  foreach($src as $key =&gt; $value){
    $newkey = explode("dim_", $key);
    $sortSrc[$newkey[1]] = $value; 
  }
  
  krsort($sortSrc);
  </code></pre>
  
  <p>It works but maybe is not so effective. Is there a way in which I can achieve this with native <code>PHP</code> functions? </p>