php生成随机字符串

<?php

echo make_random_str();

function make_random_str()
{
    $arr = ["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","1","2","3","4","5","6","7","8","9","0",];

    $max = count($arr)-1;
    $aa = mt_rand(0,$max);
    $bb = mt_rand(0,$max);
    $cc = mt_rand(0,$max);
    $dd = mt_rand(0,$max);
    $ee = mt_rand(0,$max);
    $ff = mt_rand(0,$max);

    return $arr[$aa].$arr[$bb].$arr[$cc].$arr[$dd].$arr[$ee].$arr[$ff];
}

 

posted @ 2015-06-04 20:03  yikai.shao  阅读(147)  评论(0编辑  收藏  举报