check the manual on the rand(); function ..

If you want to make sure this number is unique .. create an array storing
all the numbers you've used once and do some nice tricks with a loop and
stuff untill you get a nice unique random number ... like this:

<?php
$UsedValues = Array();

function GetRandomNumber() {
        while(  $Rand = round( rand(0, 1000000000000000) )  ) {
        # Using round() to round the float returned by rand()

                if (!in_array($Rand, $UsedValues)) return $Rand;
                array_push($UsedValues, $Rand);
        }
};

?>

-----Oorspronkelijk bericht-----
Van: Awlad Hussain [mailto:[EMAIL PROTECTED]
Verzonden: donderdag 19 juni 2003 10:47
Aan: [EMAIL PROTECTED]
Onderwerp: [PHP] unique random id


How do i generate a unique random number?

thanks

awlad





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to