Advertisement
jchaven

Put limit on line breaks using nl2br()

Jan 12th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.25 KB | None | 0 0
  1. function nl2br_limit($string, $num){
  2.  
  3.     return preg_replace('/\n/', '<br/>', preg_replace('/(\s{'.$num.'})\s+/','$1', $string));
  4.     }
  5.  
  6. http://stackoverflow.com/questions/3027277/php-nl2br-limit-x-amount
  7. http://stackoverflow.com/users/365047/kr1zmo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement