Jump to content

Recommended Posts

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.

 

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]}");
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.