note 30937 added to function.substr

From: Date: Thu, 03 Apr 2003 19:53:29 +0000
Subject: note 30937 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-46181@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+30937 http://master.php.net/manage/user-notes.php?action=delete+30937 http://master.php.net/manage/user-notes.php?action=reject+30937

« previous php.notes (#46181) next »