Я работаю над своим 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 />
тега перед строками?
Спасибо.