PHP如何批量生成手机号-使用PHP 如何生成一组不重复的手机号码?

<?php
//匹配手机号的正则表达式 #^(13[0-9]|14[47]|15[0-35-9]|17[6-8]|18[0-9])([0-9]{8})$#
$arr = array(
130,131,132,133,134,135,136,137,138,139,
144,147,
150,151,152,153,155,156,157,158,159,
176,177,178,
180,181,182,183,184,185,186,187,188,189,
);
for($i = 0; $i < 100; $i++) {
$tmp[] = $arr[array_rand($arr)].' '.mt_rand(1000,9999).''.mt_rand(1000,9999);
}
$my_phone_num=array_unique($tmp);
foreach($my_phone_num as $val){
$sjs=createRandomStr(4);
echo "u".substr_replace($val,$sjs,3,5)."<br/>";
}
//生成随机大写字母
function createRandomStr($length){
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';//26个字符
$strlen = 26;
while($length > $strlen){
$str .= $str;
$strlen += 26;
}
$str = str_shuffle($str);
return substr($str,0,$length);
}
?>
上一篇:LeetCode之263. Ugly Number


下一篇:CentOS下redis集群安装