public function index(){
$array = array();//定义数组
for($a=0;$a<100000;$a++){
$numebr = rand(6, 10);
$code = $this->createNonceStr($numebr);
$array[$j]['code'] = $code;
}
$num = 100;//每次导入条数
$limit = ceil(count($array)/$num);
for($i=1;$i<=$limit;$i++){
$offset=($i-1)*$num;
$data = array_slice($array,$offset,$num);
$result = model('codeList')->insertAll($data);
};
}
//生成随机字符
private function createNonceStr($length = 10) {
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
$str = "";
for($i = 0; $i < $length; $i ++) {
$str .= substr ( $chars, mt_rand ( 0, strlen ( $chars ) - 1 ), 1 );
}
return $str;
}
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!