note 28585 added to function.substr
| From: | arne dot hartherz at gmx dot net | Date: | Fri, 17 Jan 2003 13:45:39 +0000 |
| Subject: | note 28585 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42270@lists.php.net to get a copy of this message | ||
you might want to cut a string, but don't want it to be interrupted right in the middle of a
word.
this function could help:
function cutstr ($string, $len) {
$i = $len;
while ($i < strlen($string)) {
if ($string[$i] == " ") {
$string = substr($string, 0, $i)."[...]";
return $string;
}
$i++;
}
return $string;
}
--
http://www.php.net/manual/en/function.substr.php
http://master.php.net/manage/user-notes.php?action=edit+28585
http://master.php.net/manage/user-notes.php?action=delete+28585
http://master.php.net/manage/user-notes.php?action=reject+28585