I'm trying to generate a unique member ID which consists of the first
letter of a user's first and last name followed by a random bunch of numbers
and characters. This is how I'm doing it and was wondering if there is
better way of doing it:
mt_srand ((double) microtime() * 1000000);
$pre_referral_ID = dechex(mt_rand(0,1000000));
//changing firstName and lastName to ALL lower case
$firstName = strtolower($firstName);
$lastName = strtolower($lastName);
//changing first letter of first and last name to Upper case
$firstName = ucfirst($firstName);
$lastName = ucfirst($lastName);
//getting the first letter or each name
$firstNameSplit = preg_split ("/[a-z]/", "$firstName");
$lastNameSplit = preg_split ("/[a-z]/", "$lastName");
//building the referralID:
$referral_ID = $firstNameSplit[0] . $lastNameSplit[0] .
$pre_referral_ID;
Thanks in advance for any suggestions.