这是我的代码
$str='<div class="borderdummydiv" style="padding: 10px;">
<div class="showcolsec" style="line-height: normal;">
<p style="font-size: 14px;" data-mce-style="font-size: 14px;"><strong>Email Template for Testing - 01:</strong></p>
<p style="font-size: 14px;" data-mce-style="font-size: 14px;"><br data-mce-bogus="1"></p>
<p></p>
<p><br></p>
<p></br></p>
<p> </br></p>
<p> <br class="ddd"></p>
<p class="ddd"></p>
<p class="ddd"><br class="ddd"></p>
<p class="ddd"></br></p>
<p class="ddd"> </br></p>
<p class="ddd"> <br class="ddd"></p>
<p style="font-size: 14px;" data-mce-style="font-size: 14px;">Email body for testing the autoresponder mails and email blasts scheduling functionality<br data-mce-bogus="1"></p>
<p style="font-size: 14px;" data-mce-style="font-size: 14px;"><strong>Email Template for Testing - 01:</strong></p><p style="font-size: 14px;" data-mce-style="font-size: 14px;"><br data-mce-bogus="1"></p><p style="font-size: 14px;" data-mce-style="font-size: 14px;">Email body for testing the autoresponder mails and email blasts scheduling functionality<br data-mce-bogus="1"></p>
</div>
</div>';
//echo $str;
echo preg_replace("/<p[^>]*>[\s| |<br [^>]*>|<\/br>]*<\/p>/", '', $str);
这是输出的html
<div class="borderdummydiv" style="padding: 10px;">
<div class="showcolsec" style="line-height: normal;">
<p style="font-size: 14px;" data-mce-style="font-size: 14px;"><strong>Email Template for Testing - 01:</strong></p>
<p style="font-size: 14px;" data-mce-style="font-size: 14px;"><br data-mce-bogus="1"></p>
<p></p>
</p>
<p>
<p>
<p> <br class="ddd"></p>
<p class="ddd"></p>
<p class="ddd"><br class="ddd"></p>
<p class="ddd">
<p class="ddd">
<p class="ddd"> <br class="ddd"></p>
<p style="font-size: 14px;" data-mce-style="font-size: 14px;">Email body for testing the autoresponder mails and email blasts scheduling functionality<br data-mce-bogus="1"></p>
<p style="font-size: 14px;" data-mce-style="font-size: 14px;"><strong>Email Template for Testing - 01:</strong></p><p style="font-size: 14px;" data-mce-style="font-size: 14px;"><br data-mce-bogus="1"></p><p style="font-size: 14px;" data-mce-style="font-size: 14px;">Email body for testing the autoresponder mails and email blasts scheduling functionality<br data-mce-bogus="1"></p>
</div>
</div>
在浏览器中显示这样
Email Template for Testing - 01:
Email body for testing the autoresponder mails and email blasts scheduling functionality
Email Template for Testing - 01:
Email body for testing the autoresponder mails and email blasts scheduling functionality