Dokładniej to pobieram szablon dla wiadomości email w którym chce w miejscu oznaczonym <!--body--> <!--endBody-->podmieniać tekst. Niestety bezskutecznie.
<?php $email = preg_replace('/(<\!\-\-body\-\->)(.*)(<\!\-\-endBody\-\->)/is', ${1}.'jakiś tekst'.${2}, $email); ?>
var_dump dla $email zwraca
Kod
string(2713) "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Wiadomość wysłana z portalu </title> <style type="text/css"> html{background-color: #dfdfdf; font-family: arial;} body {margin: 20px 5%; width: 90%; min-width: 600px; background-color: #fff; box-shadow: 0 0 5px 1px rgba(0,0,0,.3);} a{color: #156b9d;} </style> </head> <body> <table collapse="1px" cellpadding="10px" cellspacing="10px" style="width: 100%; font-size: 14px;"> <thead style="border-bottom: 1px solid #dfdfdf;"> <tr> <td colspan="2" style="text-align: right; border-bottom: 1px solid #cfcfcf;"> <h1 style="font-size: 30px; color: #16498d;">tytul</h1> </td> </tr> </thead> <tbody> <tr style="line-height: 18px;"> <td colspan="2" id="wrapper"> <!--body--> <!--endBody--></td> </tr> <tr> <td colspan="2" style="background-color: #ededed; border: 1px solid #b7b7b7; font-size: 12px;">Ta wiadomość została wygenerowana automatycznie. Prosimy na nią nie odpowiadać.</td> </tr> <tr> <td colspan="2" style="border-bottom: 1px solid #cfcfcf;"> Pozdrawiamy,<br/> <br/><br/> </td> </tr> </tbody> <tfoot> <tr style="color: #505050; font-size: 13px;"> <td style="text-align: left;"> </td> <td></td> </tr> </tfoot> </table> </body> </html>"