Jump to content

[SOLVED] Generate 3 digit number WITH leading 0s


grunshaw

Recommended Posts

For those of you that have seen and helped me with my other post about formatting and splitting a variable string, you will know i'm working on a mobility system for the visually impaired. One of the requirements is to have a Map ID (or Route ID) that should be 3 digits and be between 001 and 099. Thats great - but I cant seem to generate one.

 

Here is what I have done, if someone can correct me, that would be greate

 

$rid=rand(1,999);
if($rid < 100){
$int="0";
$int.="$rid"; }
if($rid < 10){
$int="00";
$int.="$rid"; }

 

It seems to work sometimes, but when I call $int it comes up blank 95% of the time.

 

All the best

James.

 

PS > Thanks for the removeal of teh CAPATCHAS who ever did it - its much appriciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.