MastodonHelp/web/lib/randstr.php

12 lines
277 B
PHP
Raw Normal View History

2023-12-26 11:16:24 +01:00
<?php
function randstr($len,$chars=null) {
if (is_null($chars))
$chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:;\'"%&/?^';
$charslen=strlen($chars)-1;
2023-12-26 11:16:24 +01:00
$str='';
for ($i=0; $i<$len; $i++)
$str.=$chars[mt_rand(0,$charslen)];
2023-12-26 11:16:24 +01:00
return($str);
}
?>