[HELP] Adding in reverse ?

Started on the old forum in October 2014 · view the original in the archive · old links redirect here

1 reply · 75 views · started 12 years ago · 1 min read

just_m3. Developer · 199 posts #1

Hellow There !!

I'm trying to build a function which counts in reverse :

for example i want to count from 000000000​1 in the following order

000000000​1 // 000000000​2 // 000000000​3 etc

the problem is on the big numbers because it needs to substitute one zero and start adding on it .

like so : 000000001​1 / eleven 0000000200 / two hundred

increment untill it reaches to 9999999999

any idea of how doing that ? , i'm not requesting full code , just "ideas" / "ways" to do it .

Thanks .

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

just_m3. Developer · 199 posts #2

Whew 😊 Done it 🙂 , enjoy the "code" 🤑 ;

for($source=1; $source<=1000000000; $source++)
{

if(strlen($source) == 1 ) {  $prefix = "000000000"; } 
if(strlen($source) == 2 ) {  $prefix = "00000000"; } 
if(strlen($source) == 3 ) {  $prefix = "0000000"; } 
if(strlen($source) == 4 ) {  $prefix = "000000"; } 
if(strlen($source) == 5 ) {  $prefix = "00000"; } 
if(strlen($source) == 6 ) {  $prefix = "0000"; } 
if(strlen($source) == 7 ) {  $prefix = "000"; } 
if(strlen($source) == 8 ) {  $prefix = "00"; } 
if(strlen($source) == 9 ) {  $prefix = "0"; } 
if(strlen($source) == 10 ) {  $prefix = ""; } 

echo $prefix.$source."<br/>";

}
👍 1
Share

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close