Jump to content

little help with my nl2br reverting function needed


Bottyz

Recommended Posts

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 /&gt. So it looks like this in the source: <br /><br />  :confused:

 

Can anyone see why? Thanks in advance!! :)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.