PHP Simple Shuffle Algorithm _php tutorial

Source: Internet
Author: User
Tags shuffle
Source: http://phpman.cn/?p=37
Tags: <无>

Code Snippets (1)

[Code] [PHP] Code

View Source Print? 01 02/**03 * @author phpman.cn04 * @date 2012/12/0405 * @todo 简单洗牌算法06 */07 08$card_num=54; //牌数09print_r(wash_card($card_num));10 11function wash_card($card_num)12{13 $cards=$tmp=array();14 for($i=0;$i<$card_num;$i++){15 $tmp[$i]=$i;16 }17 18 for($i=0;$i<$card_num;$i++){19 $index=rand(0,$card_num-$i-1);20 $cards[$i]=$tmp[$index];21 unset($tmp[$index]);22 $tmp=array_values($tmp);23 }24 return $cards;25}26?>

http://www.bkjia.com/PHPjc/735158.html www.bkjia.com true http://www.bkjia.com/PHPjc/735158.html techarticle Source: http://phpman.cn/?p=37 Tags: no code Snippets (1) [code] [PHP] Code view source print? PHP/** * @author phpman.cn * @d Ate 2012/12/04 * @todo simple Shuffle ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.