论坛首页· 友情链接申请·申请版主· 广告投放· 道具中心· 设为首页· 收藏本站
发新话题
打印

用php获得产生随机数的办法

本主题由 Beverly 于 2008-11-17 22:29 设置高亮

用php获得产生随机数的办法

复制内容到剪贴板
代码:



function domake_password($pw_length)
{
$low_ascii_bound=48;
$upper_ascii_bound=57;
$notuse=array(58,59,60,61,62,63,64,73,79,91,92,93,94,95,96,108,111);
while($i<$pw_length){

  mt_srand((double)microtime()*1000000);
  $randnum=mt_rand($low_ascii_bound,$upper_ascii_bound);
  if(!in_array($randnum,$notuse)){
   
   if ($i==0 && $randnum==0) {
   
    $i=0;
    $password1='';
    domake_password(4);
   }
   $password1=$password1.chr($randnum);
   $i++;
  }
}
return $password1;
}
从易做事,从简做人。埋头做事,低头做人。不予他求,只扪自力。休言酸骚,命运求己。

TOP

发新话题