note 30937 deleted from function.substr by aidan
| From: | aidan@php.net | Date: | Sat, 03 Jul 2004 07:46:16 +0000 |
| Subject: | note 30937 deleted from function.substr by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72371@lists.php.net to get a copy of this message | ||
Note Submitter: jesus@home.com
----
How to make a nice trim of text without break words in the middle :
$maxTextLenght=125;
$aspace=" ";
if(strlen($text) > $maxTextLenght ) {
$text = substr(trim($text),0,$maxTextLenght);
$text = substr($text,0,strlen($text)-strpos(strrev($text),$aspace));
$text = $text.'...';
}