Page 1 of 1

Split long words in strings WITHOUT ruining HTML

Posted: Sat Mar 08, 2003 8:18 am
by Caliber
Lets say that I've got a string, $mystring, with lots of text, including a couple of very long words.
I want a function that splits all long words, so that there are no words larger than 40 characters, in the string.

BUT! I want everything that is between the < and > tags to stay unaffected by the function. So if I have a very long URL in an IMG src-tag or A href-tag, the URL may not be split.

Hope that you can help me.
Thanx in advance

Posted: Sat Mar 08, 2003 6:48 pm
by patrikG
What your probably looking for is some hyphenation... there is one script at hotscripts.com (http://www.hotscripts.com/Detailed/14316.html) - I personally haven't used it, but it might be worth a look. With some tweaking it might be able to do what you need.