I have a PHP function to catch long URLs and trim them so they don’t break my site’s formatting. I have wordwrap catching sentences but I can’t stop text like this:
‘aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa’
How would I stop user input like that ?
The things I’ve tried work if there’s dashes present (and I’ve tried ­ too in some functions) but none affect the above. It’s for a forum and this is the last bit of user input I can’t stop breaking my site ! Thanks for your help in advance.
wordwrap()will break up long words if you includeTRUEas the fourth parameter:This will insert a break at or before 30 characters.
TRUEis required to force a break in long words. IfFALSE(the default) is used, the lines are broken only on spaces.