Created
May 9, 2017 14:34
-
-
Save Kcko/6e5dea80fd022a16e1f8772af76e4cb4 to your computer and use it in GitHub Desktop.
Wrap text into paragraphs
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
<?php | |
$text = <<<TEXT | |
Morbi nisl tortor, consectetur vitae laoreet eu, lobortis id ipsum. Integer scelerisque blandit pulvinar. Nam tempus mi eget nunc laoreet venenatis. Proin viverra, erat at accumsan tincidunt, ante mi cursus elit, non | |
congue mauris dolor ac elit. Maecenas mollis nisl a sem semper ornare. Integer nunc purus, dapibus nec dignissim sed, dictum eget leo. Etiam in mi ut erat pretium fringilla sed | |
TEXT; | |
$paragraphedText = "<p>" . implode( "</p>\n\n<p>", preg_split( '/\n(?:\s*\n)+/', $text ) ) . "</p>"; | |
echo $paragraphedText; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment