1.直接获取从min-max的数,例如1-20:
$randnum=mt_rand(1, 20);
2.在一个数组里面随机选择一个(验证码的时候需要字母、数字混合的情况)
function randUid(){ $str="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20";//要显示的字符,可自己进行增删 $list=explode(",", $str); $cmax=count($list) - 1; $randnum=mt_rand(0, $cmax); $uid=$list[$randnum]; }
共0条 [查看全部]相关评论