Bottyz Posted October 8, 2010 Share Posted October 8, 2010 Hi all, I wrote this function: function nl2br_revertfull($str) { $br = preg_match('`<br>[\\n\\r]`',$str) ? '<br>' : '<br />'; $str = html_entity_decode(preg_replace('`'.$br.'([\\n\\r])`', '$1', $str)); $str = str_replace('&', '&', $str); return str_replace('£', '£', $str); } Which reverts nl2br & htmlencoded text from a db back for use in my webpage. All works beautifully except it seems if there are two <br /><br /> 's in a row it will only convert one and leave the other as <br />. So it looks like this in the source: <br /><br /> Can anyone see why? Thanks in advance!! Quote Link to comment Share on other sites More sharing options...
Pawn Posted October 8, 2010 Share Posted October 8, 2010 Why would you gunk up your data with <br />'s and HTML entities before storing it? Keep the database contents clean and use nl2br(); etc. when you actually display the data. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.