title: Switches with identical cases
body: <p>I'm trying to create a page which basically pulls video streams and organises them by viewer count so the one with the most views is at the top of the page.</p>
  
  <p>I'm fairly new to PHP so the way I've done it is extremely inefficient and long but the main thing to know is I use nested switches. </p>
  
  <p>This works perfectly when every video has a different number of viewers above 0. My problem comes when 2 videos have the same amount of viewers. When this happens all streams retain their original order.</p>
  
  <p>Here is a stripped down version of the piece of code causing the problem.</p>
  
  <pre><code>$viewarray = array($viewers1, $viewers2, $viewers3, $viewers4);
  
  rsort($viewarray, SORT_NUMERIC);
  
  for ($z=0; $z&lt;=3; $z++)
  {
  if ($viewarray[$z] == 0) {break;}
  switch($viewarray[$z]) 
  {   
      case $viewers1:
          switch($z)
          {
              case 0:
                  //code which implements the re-ordering
              case 1:
              case 2:
              case 3:
          }
          break;
      case $viewers2:
          switch($z)
          {
              case 0:
              case 1:
              case 2:
              case 3:
          }
          break;
      case $viewers3:
          switch($z)
          {
              case 0:
              case 1:
              case 2:
              case 3:
          }
          break;
      case $viewers4: 
          switch($z)
          {
              case 0:
              case 1:
              case 2:
              case 3:
          }
          break;      
  }
  }
  </code></pre>
  
  <p><code>$viewarray</code> is sorted so that it creates a list of the viewer numbers in correct order. The switch then checks each of these numbers against the actual number of viewers for each stream to find the one it matches. </p>
  
  <p>I thought if a switch argument matched 2 cases it would just pick the first one but sadly not. I have tried replacing it with if statements as well but the same thing happens.</p>
  
  <p>Any help would be appreciated.</p>