preg_replace '

' with '
'?

前端 未结 2 1923
野趣味
野趣味 2021-02-14 08:31

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 08:59
    $content = preg_replace('#<p(.*?)>(.*?)</p>#is', '$2<br/>', $content);
    
    0 讨论(0)
  • 2021-02-14 09:15

    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)
提交回复
热议问题