Page 1 of 1

Require PHP Code:Generate [01-99]

Posted: Fri Jun 17, 2005 2:51 am
by iqueen
Require a php function that can generate a string array by input string.
eg:
input:abc[01-99]
return:abc01,abc02,abc03... abc99;
input:abc[1-99]
return:abc1,abc2,abc3...abc10...abc99
---
Any help is thankful.

Posted: Fri Jun 17, 2005 3:54 am
by phpScott
don't double post as you will get in trouble from the mods. :(

Posted: Fri Jun 17, 2005 4:49 am
by patrikG
phpScott wrote:don't double post as you will get in trouble from the mods. :(
That's right. Here's the hammer of doom

Image

or, if you prefer, the sword of damocles

Image

I had to delete your double-post, which I don't like to do. Don't do it again.

Posted: Fri Jun 17, 2005 4:58 am
by iqueen
sorry,
after i have pasted in regex board, I thought maybe I should post it in php code board.
:(

Posted: Fri Jun 17, 2005 5:04 am
by iqueen
phpScott wrote:don't double post as you will get in trouble from the mods. :(
how to delete the post ?

Posted: Fri Jun 17, 2005 5:07 am
by patrikG
There's a little (x)-button on your post if you would wish to delete it. But since I've done it for you, there's nothing for you to do this time around.

Posted: Fri Jun 17, 2005 5:11 am
by iqueen
patrikG wrote:There's a little (x)-button on your post if you would wish to delete it. But since I've done it for you, there's nothing for you to do this time around.
thanks.

Posted: Fri Jun 17, 2005 5:30 am
by Bennettman
It'd be possible to do this via range.

Basically, extract the stuff inside the brackets, split it, pop them into a range() to make an array, then loop through the new array to create your string. To get the double digit behaviour, you'd have to have it check the number of digits in the low number and use that to add extra 0s for single-digit numbers in the array.

Posted: Sun Jun 19, 2005 7:48 pm
by iqueen
Bennettman wrote:It'd be possible to do this via range.

Basically, extract the stuff inside the brackets, split it, pop them into a range() to make an array, then loop through the new array to create your string. To get the double digit behaviour, you'd have to have it check the number of digits in the low number and use that to add extra 0s for single-digit numbers in the array.
Thanks so much, that 's what I want.