title: Rand(); with exclusion to and already randomly generated number..?
body: <p>I have a function which calls a users associated users from a table. The function then uses the rand(); function to chose from the array 5 randomly selected userID's however!... </p>
  
  <p>In the case where a user doesnt have many associated users but above the min (if below the 5 it just returns the array as it is) then it gives bad results due to repeat rand numbers...</p>
  
  <p>How can overcome this or exclude a previously selected rand number from the next rand(); function call.</p>
  
  <p>Here is the section of code doing the work. Bare in mind this must be highly efficient as this script is used everywhere.</p>
  
  <pre><code>$size = sizeof($users)-1;
      $nusers[0] = $users[rand(0,$size)];
      $nusers[1] = $users[rand(0,$size)];
      $nusers[2] = $users[rand(0,$size)];
      $nusers[3] = $users[rand(0,$size)];
      $nusers[4] = $users[rand(0,$size)];
  
      return $nusers;
  </code></pre>
  
  <p>Thanks in advance!
  Stefan</p>