title: Sorting arrays: second last
body: <pre><code>ksort ($votes);
          foreach ($votes as $total =&gt; $contestant){
          $ordervotes[]= $contestant;
          } 
  
          echo "&lt;li&gt; And the winner is: {$ordervotes[4]}&lt;/li&gt;";
          echo "&lt;li&gt; And the loser is: {$ordervotes[0]}&lt;/li&gt;";
          echo "&lt;li&gt; {$ordervotes[1]} came second last&lt;/li&gt;";
  </code></pre>
  
  <p>This works fine when none of the '$total's are the same, if they are the same i get an error code. I realise I could use the 'max/min' to get the first and last elements of the array, but how do i go about finding the second last?</p>
  
  <p>Thank you</p>
  
  <p>Joe </p>