How to strip everything between a key phrase and an ending tag?
Posted
by
user3620142
on Stack Overflow
See other posts from Stack Overflow
or by user3620142
Published on 2014-06-11T15:15:25Z
Indexed on
2014/06/11
15:24 UTC
Read the original article
Hit count: 158
I am trying to strip everything between a key phrase and ending tag but for some reason it is not working. I always get blank data. I've tried many different ways but no luck.
Basically I have a script that connect to IMAP and store emails into MySQL as service tickets. It works great but I am trying to strip off everything except for user reply because currently if a user reply to an email it re-inserts the entire email into MySQL. I added a key phrase at the top of all outgoing emails .
Structure is as below:
--Reply below this line to respond-- ------------------------------------------------------------------------------------ Email body message...
When replying to the message, it becomes:
New Message reply...... --Reply below this line to respond-- old message body.
I would only like to insert the new reply message only.
This is what I've got so far:
$message = strip_tags($message, "<br><div><p><u><hr></section>");
$message=preg_replace("</p>", "br /", $message);
$message=preg_replace('#--REPLY above this line to respond--(.*?)</section>)#s', ' ', $message);
$message=clean("<br/><hr><u>Received On $rep_date / $from_email</u><br><br/>$message");
It inserts the Received On date and From but $message
is blank.
If I remove $message=preg_replace('#--REPLY
above this line to respond--(.*?)</section>)#s', ' ', $message);
it inserts the entire email.
Any suggestion on what i am doing wrong?
© Stack Overflow or respective owner