Tuesday, 20 August 2013

mt_rand in function causing parse error

mt_rand in function causing parse error

I am working from some code I found online but modified the function a
little bit.
My function is
function generate_random_password($length=10)
{
$letters = 'bcdfghjklmnprstvwxzaeiou';
$result = '';
for($i=0; $i<$length; $i++)
{
$result =. ($i%2) ? $letters[mt_rand(19, 23)] :
$letters[mt_rand(0, 18)];
}
return $result;
}
And I am echoing the random password like this
echo generate_random_password($_GET['length']);
The moment I added the mt_rand() in the $result line it stopped working.
Any help would be appreciated. Thanks.

No comments:

Post a Comment