3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string='This is a space after a <br> break. This is 2 spaces after a <br> break. This is a tab after a <br> break. This is a newline after a <br> break'; var_export(str_replace(['<br> ','<br /> '],['<br>','<br />'],$string)); // if you KNOW there is only one space echo "\n\n"; var_export(preg_replace('~<br(?: /)?>\K\s+~i','',$string)); // if you want to remove all spaces, tabs, newlines

preferences:
24.73 ms | 406 KiB | 5 Q