Sjoerd Maessen blog

PHP and webdevelopment

Archive for the ‘formatting’ tag

Limit the number of newlines in a string

without comments

A very short blog post this time. I often use the following short function to limit the number of breaks/newlines in comments that people can submit on a news article or other user input. You can easily limit the number of characters in a comment by using the PHP strlen function, but the comment can still use a lot of vertical space on your website if the user uses 5 breaks in his comment. See the function below to prevent this type of comments:
Read the rest of this entry »

Written by Sjoerd Maessen

January 28th, 2010 at 10:44 pm

Posted in Regexp

Tagged with , , ,