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

Need to Generate Random number

I need to generate a random number of 12 characters long I.E. and put it into a variable

001294818387
102948582891
390012948214
0
thaburner
Asked:
thaburner
3 Solutions
 
glcumminsCommented:
See http://www.php.net/rand :

$var = rand(100000000000, 999999999999);
0
 
nplibCommented:
echo mt_rand(0, 999999999999);
0
 
nplibCommented:
$var = mt_rand(0, 999999999999);
0
 
rivusglobalCommented:
http://ca3.php.net/manual/en/function.mt-rand.php

echo mt_rand(0, 999999999999);

With returns of less than 12 digits long, you can create a function to add the zeros in front of the generated value.
0
 
thaburnerAuthor Commented:
worked perfects thanks....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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