note 22623 added to function.substr

From: Date: Tue, 25 Jun 2002 15:48:16 +0000
Subject: note 22623 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-32177@lists.php.net to get a copy of this message
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.'...'; } -- http://www.php.net/manual/en/function.substr.php http://master.php.net/manage/user-notes.php?action=edit+22623 http://master.php.net/manage/user-notes.php?action=delete+22623 http://master.php.net/manage/user-notes.php?action=reject+22623

« previous php.notes (#32177) next »