Re: How do I do this PERL in PHP?
| From: | Don Read | Date: | Wed, 17 Sep 2003 15:08:03 +0000 |
| Subject: | Re: How do I do this PERL in PHP? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-162886@lists.php.net to get a copy of this message | ||
On 16-Sep-2003 Susan Ator wrote:
> I have a text file with the following format:
>
> <TO> name
> <SUBJECT> stuff
> <MESSAGE>
> message text
> message text
> message text
>
<snip>
If you're sure the format is exactly that, then ...
$pat=array(
'<SUBJECT>',
'<MESSAGE>',
);
$marker='<FOO>';
$data=file_get_contents('dafile.txt');
$msgblks=explode('<TO>', $data);
foreach($msgblks as $blk) {
list($to, $subj, $msg) =
explode($marker,preg_replace($pat, $marker, $blk));
...
do__your_stuff($to, $subj, $msg);
...
}
Regards,
--
Don Read dread@ispwest.com
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.