<?php
function generateRandomString($length = 15) {
return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)))), 1, $length);
}
$db = new PDO('mysql:host=127.0.0.1;dbname=random', 'root', 'xxxxxxx');
$stmt = $db->prepare("INSERT INTO random(`random`) VALUES(?);");
for ($i = 0; $i <= 150000; $i++) {
$stmt->execute(array(generateRandomString()));
}
php 生成随机字符串
最新推荐文章于 2023-03-29 18:05:45 发布