Will Fris's WordPress Weblog











{20150724}   php’s nl2br is evil

Line-breaks <br /> are something for poetry and stuff.
Use paragraphs <p />.
They make up a <section /> or <article />.


if ( !function_exists( 'nl2p' ) ) {
    function nl2p ( $text ) {
        $peed = ''
            . '<p>'
            . str_replace(
                  array( "\r\n" , "\r" , "\n" )
                , '</p><p>'
                , $text
            )
            . '</p>'
        ;
        return $peed;
    }
}
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

et cetera
%d bloggers like this: