我正在使用我的 php 从电子邮件正文中获取电子邮件数据。我在删除<br />字符串之前的标签时遇到了问题This message was created。
这是完整的电子邮件正文:
<br />
<br />
This message was created automatically by mail delivery software.<br />
<br />
A message that you sent could not be delivered to one or more of its<br />
recipients. This is a permanent error. The following address(es) failed:
<br />
<br />
fvsafsafsaf@shitmail.com<br />
retry timeout exceeded
我试过这个:
$top_message = str_replace('<br /> <br /> This message', 'This message', $top_message);
我也试过这个:
$top_message = str_replace('<br /> <br />', '', $top_message);
它不会<br />在字符串之前删除标签,也不会发生任何事情。
这是完整的代码:
$body = imap_body($mailbox, $email_number, 2);
$email_body = utf8_decode(imap_utf8($body));
$top_message = getBetween($email_body, 'charset=us-ascii', 'exceeded') . 'exceeded';
$top_message = nl2br($top_message);
$top_message = str_replace('<br /> <br /> This message', 'This message', $top_message);
echo $top_message
我想要实现的是,当我从电子邮件正文中获取电子邮件数据时,我想用来为每一行nl2br添加<br />标签,然后我想删除<br />字符串之前的两个标签This message was created。
我想让它显示如下:
This message was created automatically by mail delivery software.<br />
<br />
A message that you sent could not be delivered to one or more of its<br />
recipients. This is a permanent error. The following address(es) failed:
<br />
<br />
name@example.com<br />
retry timeout exceeded
你能告诉我一个例子我如何能够<br />在字符串之前删除两个标签吗?
谢谢你。
阿晨1998
一只名叫tom的猫
MMTTMM