homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

exctract entire lines from text file to array
Inspector Mills

Msg#: 4461238 posted 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.




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

Msg#: 4461238 posted 2:02 pm on Jun 12, 2012 (gmt 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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved