note 70404 added to function.rand
| From: | php-general at lists dot php dot net | Date: | Sun, 15 Oct 2006 07:24:58 +0000 |
| Subject: | note 70404 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118538@lists.php.net to get a copy of this message | ||
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;
}
----
Server IP: 203.89.181.184
Probable Submitter: 219.88.69.130
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- https://master.php.net/note/edit/70404
Del: integrated -- https://master.php.net/note/delete/70404/integrated
Del: useless -- https://master.php.net/note/delete/70404/useless
Del: bad code -- https://master.php.net/note/delete/70404/bad+code
Del: spam -- https://master.php.net/note/delete/70404/spam
Del: non-english -- https://master.php.net/note/delete/70404/non-english
Del: in docs -- https://master.php.net/note/delete/70404/in+docs
Del: other reasons-- https://master.php.net/note/delete/70404
Reject -- https://master.php.net/note/reject/70404
Search -- https://master.php.net/manage/user-notes.php