3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = '<p>my text 1</p> some other content <p>some other paragraph followed by an html line break</p><br> etc...'; $text = nl2br($text); $regex= '#<\/p>(<br\s?\/?>)#'; $text = preg_replace($regex, '</p>', $text); echo $text;

preferences:
27.15 ms | 405 KiB | 5 Q