http://jsfiddle.net/monteslu/ vcKdF/
每新增一条记录,就会创建一个类似“vcKdF”这样的KEY
求这个KEY的算法
谢谢!
52 取 5 的组合(2598960 种,够用了),如果重复了就换一个
<?phpfunction getRandStr($len){ $chars = array("0", "1", "2","3", "4", "5", "6", "7", "8", "9"); //换成a-z,A-Z 52种 $charsLen = count($chars) - 1; shuffle($chars); $output = ""; for ($i=0; $i<$len; $i++){ $output .= $chars[mt_rand(0, $charsLen)]; } return $output; }?>
function getRandStr($len){ $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZzbcdefghijklmnopqrstuvwxyz"; $output = ""; for ($i=0; $i<$len; $i++){ $output .= $str{mt_rand(0, 52)}; } return $output; }
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号