I'm trying to write a function that produces a random User ID and password. However, I'm finding that the random number generation isn't very random and that it's repeating itself. Here's the code:
function generateId()
{
srand(time());
$Pool = "ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnopqrstuvwxyz";
$first_char = substr($Pool,(rand()%(strlen($Pool))),1);
$last_char = substr($Pool,(rand()%(strlen($Pool))),1);
$number=rand(1,10000);
$id = $first_char;
$id .= strval($number);
$id .= $last_char;
return $id;
}
I am calling the function twice in my main script and are finding that (a) it's simply repeating the same value even though I'm calling the function twice and (b) it doesn' t take long before it repeats the supposedly random numbers.
Any help would be appreciated.