note 70404 deleted from function.rand by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter:  

----

correction from the function below... this works better:

function randomselection($sql, $c) {
 $data = getdata($sql);
 $totalcount = count($data);
 $j = array();
 if($totalcount < $c) {//not enough data points
  return $data;
 }
 for($i = 0; $i < $c; $i++) {
  $j[$i] = mt_rand(0,$totalcount-1);
  $newdata[$i] = $data[$j[$i]];
  unset($data[$j[$i]]);
  sort($data);
  $totalcount--;
 }
 return $newdata;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.