• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

PHP random number, not starting with zero

Hellow all,

I need to create a random number of 10 digits (member id). But the number must not start with a zero.

How can this be done.

greetz,
walter
0
wal_toor
Asked:
wal_toor
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
logic:
create a random number between 0 and 8999999999   and then simply add 1000000000 to it
0
 
shobinsunCommented:
Hi.,

The random number generated is a 32bit integer. That limits it to 9 digits maximum. Of course you could just stick two 5 digit randoms together. They are random after all...

echo mt_rand(10000,99999) . mt_rand(10000,99999) ;
0
 
wal_toorAuthor Commented:
I was thinking way to complex. Thanks guys
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now