Try it: Prevent (too) long strings
Use this form to test the function. Notice the converted string below the textarea. I'm using a limit of three, following characters.
Related PHP functions:
preg_match | explode | implode | preg_split | count
Click here for the PHP script: Prevent long strings