preg_replace '

' with '
'?

前端 未结 2 1492
礼貌的吻别
礼貌的吻别 2021-02-14 08:54

I have my code removing the

starting tags, but now I want to replace the ending

tags with line breaks. How can I do this?

相关标签:
2条回答
  • 2021-02-14 09:06
    $content = preg_replace('#<p(.*?)>(.*?)</p>#is', '$2<br/>', $content);
    
    0 讨论(0)
  • 2021-02-14 09:18

    use str_replace instead of preg_replace, so:

    $content = '<p>This is a new content for missing slash</p>';
    $newcontent = preg_replace("/<p[^>]*?>/", "", $content);
    $newcontent = str_replace("</p>", "<br />", $newcontent);
    
    0 讨论(0)
提交回复
热议问题