Jump to content

[SOLVED] Question with numbers and generating them..


monkeytooth

Recommended Posts

Now this may be a very stupid question with a really simple answer, and I have probably been staring at the answer for awhile now.. but I'm going to ask anyway..

 

I need to generate a list of numbers, well say 1-100, which isn't to hard I know, with a while loop, but heres the part im kicking myself over with.. I dont want 1,2,3,4,5,6,7,8,9,10.. I want ouput like 001,002,003,004,005,006,007,008,009,010.. and so on to 100 and in some cases more.. but Im assuming if it can be done one way a slight alteration can be made to go higher..

 

anyway heres a pic sample..

 

numbers.jpg

 

so what do you think possible? im almost sure it is,but for the life of me I can't get it right..

Link to comment
Share on other sites

I have another question, this one im not to sure about it though.. Is it possible to take an input of any kind (number only). And have it get the highest count for that total ammount of numbers.. If that makes sence.

 

Ok lets say I want to go from 1-9999 with the above function. But all I want to do is input the number 4 and work something up that can generate the highest number possible with 4 digits: 9999. Or I want to pop the number 2 in the input and have it go come up with 99, or 3 and have it figure out that 3 numbers is 999..

 

I think in typing this out I have come up with my own solution to this particular answer but Ill keep the question and post the concept to find out if you all think its doable..

 

echo str_pad($i, 3, "9", STR_PAD_LEFT);

 

where I turn the 3 in the string to a var that will take my input and do as i wish.. In fact Im just gonna go try that now.. but if someones got a better idea that that I am for it  ;D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.