php扑克比较大小,php 扑克牌代码的简单例子

php 扑克牌代码,如下:

/***

*

* A simple class to cut a deck of cards

* @version CVS: $Id:$

* @since Class available since Release 1.0.0

* Example use

*

* $cards = new cards;

* echo $cards->cut();

* www: jbxue.com

*/

class cards{

/**

*

* Declare our deck variable

*

*/

private $deck;

/**

*

* Constructor.. duh!

*

*/

function __construct(){

/*** set the deck array variable ***/

$this->deck=$this->setDeck();

}

/**

*

* Function set Deck

*

* @access private

*

* @return array

*

*/

private function setDeck(){

return array("ah", "ac", "ad", "as",

"2h", "2c", "2d", "2s",

"3h", "3c", "3d", "3s",

"4h", "4c", "4d", "4s",

"5h", "5c", "5d", "5s",

"6h", "6c", "6d", "6s",

"7h", "7c", "7d", "7s",

"8h", "8c", "8d", "8s",

"9h", "9c", "9d", "9s",

"th", "tc", "td", "ts",

"jh", "jc", "jd", "js",

"qh", "qc", "qd", "qs",

"kh", "kc", "kd", "ks");

}

/**

*

* Function get Key get the array key

*

* @access private

*

* @return INT

*

*/

private function getKey(){

shuffle($this->deck);

return array_rand($this->deck);

}

/**

*

* @Function cut, get the value of the array key

*

* @access public

*

* @return string

*

*/

public function cut(){

return $this->deck[$this->getKey()];

}

} /*** end of class ***/

$cards = new cards;

echo $cards->cut();

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值