PHP

php随机生成姓名,手机号,6位数

2016-12-20  本文已影响141人  七百年前

1.随机生成姓名,手机号,6位数

方法很简单 可以参考

/**
 * 获取抽奖号码   造数据
 */
public function zaosu()
{

    for ($i = 0; $i < 50; $i++) {
        $xing = "赵,钱,孙,李,周,吴,郑,王,冯,陈,楚,卫,步,吕,张";
        $ming = "忽,如,一,夜,春,风,来,千,树,万,树,梨,花,开,春,江,潮,水,连,海,平,海,上,明,月,共,潮,生";
        $xing = explode(",", $xing);
        shuffle($xing); //随机重新排序数组
        $newstr = implode('', $xing); //把数据转为字符串

        $ming = explode(",", $ming);
        shuffle($ming); //随机重新排序数组
        $newsming = implode('', $ming); //把数据转为字符串

        $t1 = substr(uniqid('', true), 15, 3);
        // var_dump(uniqid('', true));
        // var_dump($t1);
        $t2 = substr(microtime(), 2, 3);
        // var_dump(microtime());
        // var_dump($t2);

        $arr['name']    = mb_substr($newstr, 0, 1, 'utf-8') . mb_substr($newsming, 0, 2, 'utf-8');
        $arr['mobile']  = '13' . substr(uniqid('', true), 19) . substr(microtime(), 2, 5);
        $arr['code_sn'] = str_pad($t1 . $t2, 6, "0", STR_PAD_RIGHT);
        //var_dump($arr['code_sn']);//exit;
        $dd = $this->db_game_gift->insert($arr);
    }
}
上一篇下一篇

猜你喜欢

热点阅读