Parsing a file line by line
| From: | Jason Williard | Date: | Wed, 26 Nov 2003 01:44:09 +0000 |
| Subject: | Parsing a file line by line | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-170970@lists.php.net to get a copy of this message | ||
I would like some assistance in creating a script that will parse a file
line by line. The file that I need to parse has a designator at the
beginning of most lines. I need the script to search for a specific
designators (listed in an array) and then send an e-mail with the
contents of each line. There will need to be a separate e-mail for each
line.
Example:
$array = array( "A120", "B120", "D120" );
Text File:
A120 Text
B120 Text
C120 Text
D120 Text
To make this more difficult... Occasionally, one of the lines may be
followed by multiple other lines containing more information. I need to
be able to get that information as well. The only distinct part of
those lines following is that they start with 15 spaces.
Example:
D120 Text Text Text Text
More Text
More Text
More Text
Does anyone have any ideas for me?
Thanks,
Jason Williard