Last active
February 17, 2020 20:12
-
-
Save ewistrand/453553c49f27f61d508f883647f6d6d5 to your computer and use it in GitHub Desktop.
Turn line breaks into paragraph tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(! function_exists('nl2p')) { | |
function nl2p($str) { | |
$arr = explode("\n", $str); | |
$out = ''; | |
for($i = 0; $i < count($arr); $i++) { | |
if(strlen(trim($arr[$i])) > 0) | |
$out .= '<p>' .trim($arr[$i]) . '</p>'; | |
} | |
return $out; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment