Shorten text with RegExp
Posted: Sat Jun 18, 2005 4:02 am
Hello together,
I would like to shorten a text and did following:
Works just fine, but if I have a long text like "I am a very, very,very long long long text."
(This example ofcourse doesn't have 360 characters) it gets split in middle of a word like this: "I am a very, very,very long long long te..."
Words shouldn't be shortened. In the above example I would like to have following result: "I am a very, very,very long long long ..."
wordwrap() is not the correct function for my problem or am I overseeing something? I guess RegExp would be the right thing, but how to?
Appreciate your help!
I would like to shorten a text and did following:
Code: Select all
$this->werbetext = substr($sesArrFoundї$i]ї'werbetext'], 0 , 360);
$this->werbetext .= "e; ..."e;;Works just fine, but if I have a long text like "I am a very, very,very long long long text."
(This example ofcourse doesn't have 360 characters) it gets split in middle of a word like this: "I am a very, very,very long long long te..."
Words shouldn't be shortened. In the above example I would like to have following result: "I am a very, very,very long long long ..."
wordwrap() is not the correct function for my problem or am I overseeing something? I guess RegExp would be the right thing, but how to?
Appreciate your help!