Newline in a guestbook
| From: | Jimmy Bäckström | Date: | Tue, 24 Apr 2001 21:33:30 +0000 |
| Subject: | Newline in a guestbook | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-50177@lists.php.net to get a copy of this message | ||
Hey guys!
I'm writing a guestbook with mysql. My probblem is that when user enter at long word like
blablablablablablablablablablablabla my html-tables gets screwed up. If someone is just fooling
around the whole page design can be destroyed. I want to know how I can make sure that no word is
longer than x characters. If a word should be longer than that, I would like the word divided into
smaller parts with a - character at the end of the first word like this:
"this is a text in the guestbook.
if there is a really long word
like blablablablablablablabla-
blablabla it is divided into
smaller parts and a - char
is added to the first word."
I thought about reading the whole message into an array, and then loop through it and for each word
check whether it is larger than x chars, and if so, change it. But couldn't that be a very
memory consuming script if it should do that for every message? Anyone knows how I could do this?