Solved

PHP random number, not starting with zero

Posted on 2009-05-08
3
273 Views
Last Modified: 2012-05-06
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
Comment
Question by:wal_toor
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 24333781
logic:
create a random number between 0 and 8999999999   and then simply add 1000000000 to it
0
 
LVL 14

Assisted Solution

by:shobinsun
shobinsun earned 250 total points
ID: 24333830
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
 
LVL 8

Author Comment

by:wal_toor
ID: 24333874
I was thinking way to complex. Thanks guys
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now