Page 1 of 1

str_replace question

Posted: Tue Oct 13, 2009 9:27 am
by MiniMonty
Hi all,

I am using .txt file to tell a Flash front end all kinds of stuff and it works fine.

One issue is that a certain string in a txt file is regularly updated. The the last line reads:
&totalimgs=12 where the number 12 is always changing (upward).

I am using str_replace to strip out the line &totalimgs= but what do I add to take out
the number that follows it which could be up to five digits ?

Best wishes
Monty

Re: str_replace question

Posted: Tue Oct 13, 2009 9:38 am
by Weiry
I couldn't tell you exactly how to do it. But i believe you would need to perform some sort of a regular expression on the remaining string for up to the next 5 numbers. Then if it meets a character not an object, the script stops.
A far less efficient method would be to explode the remaining string, then loop through each singular character to check if its a number (for up to 5) and extract it.
I am not very familiar with regex code though, but thats how i believe it would be done efficiently.