$num,指定生成位数,
$similar 是否包含相似字符
$type 字符类型 true 大写.false 小写
*/
function randText($num,$type = false,$similar = false){
//组合
$chars = array();
$chars = array_flip(array_merge(range(0,9),range('a','z')));
if($similar === false){
//去掉相似
unset($chars[0],$chars[1],$chars[2],$chars[5],$chars[8],$chars['b'],$chars['i'],$chars['o'],$chars['q'],$chars['s'],$chars['u'],$chars['v'],$chars['v']);
}
//进行遍历
for($i = 0; $i < $num; $i++ ){
$str .=array_rand($chars);
}
if($type === true){
$str = strtoupper($str);
}
return str_shuffle($str);
}