Welcome to WebmasterWorld Guest from 54.146.201.80

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)

New User

joined:Mar 13, 2011
posts: 6
votes: 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 June 12, 2012 (gmt 0)

Administrator

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

joined:July 31, 2003
posts:12533
votes: 0


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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members