PHP – br2nl

As a reverse function of nl2br you can use:

<?php
/**
 * reverse function for nl2br
 * @param $string - string with br's
 * @return string - string with \n
 */
function br2nl($string)
{
    return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $string);
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.