本帖最后由 satans18 于 2013-04-02 19:33:14 编辑
http://jsfiddle.net/monteslu/
------解决方案--------------------52 取 5 的组合(2598960 种,够用了),如果重复了就换一个
------解决方案--------------------<br />
<?php<br />
function getRandStr($len){ <br />
$chars = array("0", "1", "2","3", "4", "5", "6", "7", "8", "9"); //换成a-z,A-Z 52种<br />
$charsLen = count($chars) - 1; <br />
shuffle($chars);<br />
$output = "";<br />
for ($i=0; $i<$len; $i++){ <br />
$output .= $chars[mt_rand(0, $charsLen)]; <br />
} <br />
return $output; <br />
}<br />
<br />
?><br />