NYCPHP Meetup

NYPHP.org

[nycphp-talk] generate random unique 8-digit number

Fernando Gabrieli fgabrieli at gmail.com
Tue Mar 10 09:18:09 EDT 2009


using tim's idea: get a uniqid, convert it to numbers and shift the
difference :)
- get a uniqid
- convert the chars to numbers using php.net/ord
- use the 8 first numbers


(would be an alternative to rand() for 8-digits)



On Tue, Mar 10, 2009 at 9:48 AM, Tim Gales <tgales at tgaconnect.com> wrote:

> chad qian wrote:
>
>> Hi,
>> I need to generate random 8-digit numbers continuously.And no duplication
>> among all those numbers.In other word,every single 8-digit number must be
>> unique.How to do php programming?
>>
> Change your specification to 13 characters and use the function uniqid
>
> Uniqid is driven by the system clock -- so it's granularity is a
> microsecond.
>
>
>
>
>
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090310/c1347a5d/attachment.html>


More information about the talk mailing list