I'm trying to read in a config file, formatted like:
I've been able to get the file contents by:
And I've tried a number of "preg_match_all" statements, but I really suck at regular expressions.
My question is:
How can I find out the number of "MESSAGE" blocks in the file, and how would I go about looping through them and printing their contents?
I have searched this forum, and have come up short.
Thanks in advance for any thoughts/suggestions!
X
Code:
<MESSAGE>
Tank number five exploded.
</MESSAGE>
<MESSAGE>
Tank #7 in need of repair
</MESSAGE>
I've been able to get the file contents by:
Code:
$comments = file_get_contents("data.txt");
And I've tried a number of "preg_match_all" statements, but I really suck at regular expressions.
My question is:
How can I find out the number of "MESSAGE" blocks in the file, and how would I go about looping through them and printing their contents?
I have searched this forum, and have come up short.
Thanks in advance for any thoughts/suggestions!
X