As shown below:
Copy code The code is as follows:
/**
* Simple shuffling algorithm
* /
$card_num=54; //Number of cards
print_r(wash_card($card_num));
function wash_card($card_num)
{
$cards= $tmp=array();
for($i=0;$i<$card_num;$i++){
$tmp[$i]=$i;
}
for($i=0;$i<$card_num;$i++){
$index=rand(0,$card_num-$i-1); index];
unset($tmp[$index]);
$tmp=array_values($tmp);
}
return $cards;
}
?>
http://www.bkjia.com/PHPjc/327706.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327706.htmlTechArticle is as follows: Copy the code as follows: ?php /*** Simple shuffling algorithm*/ $card_num=54; //Number of cards print_r(wash_card($card_num)); function wash_card($card_num) { $cards=$tmp=array()...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn