On Sat, 2006-09-09 at 08:54 -0500, Wade Smart wrote: > Here is what I need to do: > 1. open a text file in a folder, > 2. scan the file for a predetermined word that marks the beginning of an > area, > 3. scan the file for a predetermined word that marks the end of an > area, > 4. copy the text between these two words, > 5. write this to another file, > 6. and go onto the next area in the same file to do this again. > > Im stuck on step 2 -5. I can use reg to find the first word but Im a bit > lost on what to do next. > I can scan for the last word, the first word but how do I maintain > accountability for the number of items to be copied within the > document?
I am not sure I am completely understanding your situation, but would something like this work: 1) Read the file into a variable, like with file_get_contents() 2) Find the numeric position of the first string, maybe with strpos() 3) Find the numeric position of the last string, again, with strpos() 4) use substr() to grab the string in between substr (filestring, firstpos, length ) where length=lastpos-firstpos http://us2.php.net/manual/en/function.substr.php 5) Write string returned in #4 to a file Put the whole thing in a loop for each file. HTH, -- Doug Registered Linux User #285548 (http://counter.li.org) ---------------------------------------- Random Thought: You will triumph over your enemy. Community email addresses: Post message: php-list@yahoogroups.com Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/php-list/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/