Note Submitter: hoffa at NOSPAM hoffa.se
----
To shuffle an array ( [0....n] )
function Shufflearr($array) {
$size = sizeof($array) - 1;
for ($x = 0; $x < $size; $x++) {
$i = rand($x, $size);
$tmp = $array[$x];
$array[$x] = $array[$i];
$array[$i] = $tmp;
}
return $array;
}
// create an array
for ($i=0; $i<10; $i++) {
$nbrarray[$i] = $i;
}
print_r($nbrarray); // before
$nbrarray = Shufflearr($nbrarray); // shuffle
print_r($nbrarray); // after
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.