note 26117 rejected from function.wordwrap by betz
| From: | betz@php.net | Date: | Fri, 18 Oct 2002 17:24:43 +0000 |
| Subject: | note 26117 rejected from function.wordwrap by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-38262@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