...

View Full Version : long strings of user input breaks formatting



Bobafart
03-14-2008, 04:49 PM
I have TEXTAREA input fields

Users can submit data.. if a long string is entered without spaces (like a URL) the string goes beyond the width of the div container.

what is a stylistically pleasing way to prevent this from occurring?


I assume exploding each word with a space and then counting the length of each word in the data. if length of a word is larger than a certain integer then add ' ...' a space followed by 3 periods

Is there another way of doing this than the way I described above?

kbluhm
03-14-2008, 04:50 PM
http://www.php.net/wordwrap

Inigoesdr
03-14-2008, 09:53 PM
If you don't want to wrap URLs you could do something like this:


$str = 'http://www.loooooooooooooooongurl.com/';
echo strlen($str) > 20 ? substr($str, 0, 20) . '...' : $str;
Where "20" is the string length limit. You could make it a variable if you want to be able to only change it in once place.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum