Welcome to WebmasterWorld Guest from 54.205.20.160

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

exctract entire lines from text file to array

   
2:43 pm on Jun 4, 2012 (gmt 0)



Hi there

I need a PHP script to extract a number of lines from a text file, and insert them into an array.

The lines that I need to extract all have the following in common:
- the line preceding it has a line of dashes, preceded by 4 spaces ;
- the line after it is blank, and then is followed by another line of dashes (with no preceding spaces).

Like this:
----------------------
Total : 26.225 %

--------------------------

Any suggestions on how to do this?

Thanks in Advance.

Mills
2:02 pm on Jun 12, 2012 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Regular expressions are likely going to be involved in the solution. You create a pattern and you can capture all the matches in an array. See preg_match() and preg_match_all() in the online PHP manual pages.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month