title: Sort a foreach loop numerically
body: <p>Within opencart, i am developing the admin panel.</p>
  
  <p>I want to show say, the top 10 stores and their respective visits.</p>
  
  <p>at the moment, i have this information within a table and my php loop is this.</p>
  
  <pre><code>  &lt;?php foreach ($stores as $store) { ?&gt;
      &lt;?php echo $store['name']?&gt;
      &lt;?php echo number_format($store['visitor'])?&gt;
    &lt;?php } ?&gt;
  </code></pre>
  
  <p>This returns data in a big mess but the data IS there!</p>
  
  <p>Alesso  20<br>
  Alice in Chains  32<br>
  Amy Winehouse  27<br>
  Avenged Sevenfold 136<br>
  Axewound  30<br>
  Axwell  6<br>
  Backstreet Boys  24 </p>
  
  <p>And so on.... for about 100 Different stores.</p>
  
  <p>What i want to know is, in the foreach loop i wish to only display the top say, 10 stores.
  the top stores with the most visits, now i have the data, but how do i go about sorting this in a foreach to only show the top 10?</p>
  
  <p>Many thanks
  Sean</p>