- var_export: documentation ( source)
- str_replace: documentation ( source)
- preg_replace: documentation ( source)
<?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