Php implements a simple shuffling algorithm. The copy code is as follows :? Php *** simple shuffling algorithm ** $ card_num54; number of cards print_r (cost _card ($ card_num); functionwashwash_card ($ card_num) {$ cards $ tmparray () is as follows:
The code is as follows:
/**
* Simple shuffling algorithm
*/
$ Card_num = 54; // Number of Cards
Print_r (wash_card ($ card_num ));
Function pai_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 );
$ Cards [$ I] = $ tmp [$ index];
Unset ($ tmp [$ index]);
$ Tmp = array_values ($ tmp );
}
Return $ cards;
}
?>
The pipeline code is as follows :? Php/*** simple shuffling algorithm */$ card_num = 54; // Number of Cards print_r (card _card ($ card_num); function card _card ($ card_num) {$ cards = $ tmp = array ()...