Created
April 3, 2012 03:25
-
-
Save juque/2289057 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| function nl2br_limit($string, $num){ | |
| return preg_replace('/\n/', '<br/>', preg_replace('/(\s{'.$num.'})\s+/','$1', $string)); | |
| } | |
| $cadena = <<<EOF | |
| uno dos tres | |
| bla bla | |
| bla bla bla bla | |
| cuatro | |
| EOF; | |
| print nl2br_limit($cadena,2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment