Anandlall12 Posted June 11, 2014 Share Posted June 11, 2014 Hey guys. 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. works great but I am trying to strip 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 . 1. structure looks like this. --Reply below this line to respond-- ------------------------------------------------------------------------------------------------ Email body message... 2. When replying to the message it becomes New Message reply...... --Reply below this line to respond-- old message body. 3. so I would only like to insert the new reply message only. This is what I 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? thank you all very much. Quote Link to comment https://forums.phpfreaks.com/topic/289112-how-to-strip-everything-between-key-phrase-and-ending-tag/ Share on other sites More sharing options...
ginerjm Posted June 11, 2014 Share Posted June 11, 2014 You're not following forum rules on posting code? Quote Link to comment https://forums.phpfreaks.com/topic/289112-how-to-strip-everything-between-key-phrase-and-ending-tag/#findComment-1482467 Share on other sites More sharing options...
Anandlall12 Posted June 11, 2014 Author Share Posted June 11, 2014 What rule am I not following? Quote Link to comment https://forums.phpfreaks.com/topic/289112-how-to-strip-everything-between-key-phrase-and-ending-tag/#findComment-1482473 Share on other sites More sharing options...
ginerjm Posted June 11, 2014 Share Posted June 11, 2014 How about reading them and finding out? Quote Link to comment https://forums.phpfreaks.com/topic/289112-how-to-strip-everything-between-key-phrase-and-ending-tag/#findComment-1482474 Share on other sites More sharing options...
Ch0cu3r Posted June 11, 2014 Share Posted June 11, 2014 Try preg_match $message =strip_tags($message, "<br><div><p><u><hr></section>"); $message =preg_replace("</p>", "br /", $message); $message = preg_match('~(.*?)(?:--Reply below this line to respond--)~is', $message, $m); $message =clean("<br/><hr><u>Received On $rep_date / $from_email</u><br><br/>{$m[0]}"); Quote Link to comment https://forums.phpfreaks.com/topic/289112-how-to-strip-everything-between-key-phrase-and-ending-tag/#findComment-1482477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.