Using standard lib version of randstr.php, which is more flexible and fast
This commit is contained in:
parent
9440903626
commit
e5b56f3e68
1 changed files with 5 additions and 6 deletions
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
|
||||
function randstr($len) {
|
||||
$chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:;\'"%&/?^';
|
||||
$charslen=strlen($chars);
|
||||
function randstr($len,$chars=null) {
|
||||
if (is_null($chars))
|
||||
$chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:;\'"%&/?^';
|
||||
$charslen=strlen($chars)-1;
|
||||
$str='';
|
||||
for ($i=0; $i<$len; $i++)
|
||||
$str.=$chars[rand(0,$charslen-1)];
|
||||
$str.=$chars[mt_rand(0,$charslen)];
|
||||
return($str);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue