+ -
当前位置:首页 → 问答吧 → 生成随机数

生成随机数

时间:2009-12-28

来源:互联网

function genRandomString($len) { $chars = array( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ); $charsLen = count($chars) - 1; shuffle($chars); $output = ""; for ($i=0; $i<$len; $i++) { $output .= $chars[mt_rand(0, $charsLen)]; } return $output; }

作者: 风吟   发布时间: 2009-12-28

不知道LZ这么些什么意思

shuffle函数已经打乱顺序了【起到随机的目的了】
为啥还mt_rand?

作者: wxllyf   发布时间: 2009-12-28

那按照二楼的意思!该怎么写?

作者: 风吟   发布时间: 2009-12-28