我的代码删除了< p>开始标签,但现在我想替换结尾的< / p>带有换行符的标签我该怎么做?
这是我有的:
$content = 'This is the content'; $newcontent = preg_replace("/<p[^>]*?>","",$content); $newcontent = preg_replace("</p>","<br />",$newcontent);
使用str_replace而不是preg_replace,所以:
原文链接:https://www.f2er.com/php/132731.html$content = '<p>This is a new content for missing slash</p>'; $newcontent = preg_replace("/<p[^>]*?>/",$content); $newcontent = str_replace("</p>",$newcontent);