The function to generate a random string is as follows
private function getRandomString($len,$char=null){
if (is_null($char)){
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
}
//随机数播种生成器
//根据参数生成随机数,mt_rand()使用
//php4.2之后就自动播种,已淘汰
mt_srand(10000000*(double)microtime());
for ($i=0,$str=" ",$lc=strlen($chars)-1;$i<$len;$i++){
$str.=$chars[mt_rand(0,$lc)];
}
return $str;
}
Can self-combined to generate all kinds of data
$user_name= [
'夏候望',
'劲冥石',
'济川烨',
'欧阳劲',
'林风眠',
'伍忘因',
'赵紫颖',
'月明溪',
'风川鸣',
'欣月馨'
];
$name_key=array_rand($user_name);
echo $user_name[$name_key];
The contents of the array can be randomly generated