need a simple preg_replace to convert all <br>
<br/>
and all possible br combinations to <br />
.
This needs to work in order so i can process a string ie:
$output = preg_replace('', '<br />', $input)
Thanks everyone!
need a simple preg_replace to convert all <br>
<br/>
and all possible br combinations to <br />
.
This needs to work in order so i can process a string ie:
$output = preg_replace('', '<br />', $input)
Thanks everyone!
[Obligatory HTML parser comment]
If you're working with unknown and non-consistent HTML (as it sounds like you are), then put down the regex, you might hurt yourself. Finding a list of tags and altering a document is what HTML parsers were built for.
Learn the PHP DOM Methods and save yourself a lot of heartache.
One RegEx to rule them all:
$output = preg_replace('/<\s*br[^>]*>/i', '<br />', $input);