- microtime: documentation ( source)
- mb_strlen: documentation ( source)
- mt_rand: documentation ( source)
- printf: documentation ( source)
<?php
$t = microtime(true);
function passgen($l = 12)
{
$r = "";
$s = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
$slen = mb_strlen($s) - 1;
for ($i = 0; $i < $l; $i++) {
$r .= $s[mt_rand(0, $slen)];
}
return $r;
}
for ($i = 0; $i < 100000; ++$i)
passgen();
printf("%0.04f\n", microtime(true) - $t);