There will probably be some situations where your code is not enough ; so, what about something like this, to do your replacement :
$html = 'this <br>is<br/>some<br />text <br />!';
$nl = preg_replace('#<brs*/?>#i', "
", $html);
echo $nl;
i.e. a bit more complex than a simple str_replace
;-)
Note : I would generally say don't use regex to manipulate HTML -- but, in this case, considering the regex would be pretty simple, I suppose it would be OK.
Also, note that I used "
"
Basically, a <br>
tag generally looks like :
<br>
- or
<br/>
, with any number of spaces before the /
And that second point is where str_replace
is not enough.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…