note 26117 added to function.wordwrap

From: Date: Fri, 18 Oct 2002 14:46:11 +0000
Subject: note 26117 added to function.wordwrap
Groups: php.notes 
Request: Send a blank email to php-notes+get-38253@lists.php.net to get a copy of this message
I have created this function which cuts line length at the desired character number, and replaces the last incomplete word with a "..." Can someone tell me if there was an easier/better/other way to do this? function line_cut($var, $length=0) { $var=substr($var, 0, $length); $var=strrev($var); $var=strchr($var, " "); $var=strrev($var); return $var."..."; } This happens to be my first function, as I am just a beginner. Please comment. Thanks! Sfarog -- http://www.php.net/manual/en/function.wordwrap.php http://master.php.net/manage/user-notes.php?action=edit+26117 http://master.php.net/manage/user-notes.php?action=delete+26117 http://master.php.net/manage/user-notes.php?action=reject+26117

« previous php.notes (#38253) next »