Page 1 of 1

Quick newb question about .txt file

Posted: Sat Jan 16, 2010 4:26 pm
by MiniMonty
Hi all,

just a quick one...

I have a .txt file which is pumping a single variable to a Flash front end.
I need a quick and dirty script to open the txt file which reads "&numReady=20",
subtract 1 from the digit, save with the string "&numReady=19" (18, 17, 16, etc.,) and close the file.

Any quick help on offer ?
I'm a newb but I know that if I had an hour I could work this out with a search or two - only I
don't have an hour - I have about 5 minutes 8O

Best wishes
Monty

Posted: Sat Jan 16, 2010 6:01 pm
by Jonah Bron
How about a one-liner?

Code: Select all

file_put_contents('file.txt', '&numReady=' . strval(intval(substr(file_get_contents('file.txt'), 10)) - 1));
I guess I'm a little late, though.