note 80996 added to function.substr
| From: | ben at enemy dot dk | Date: | Sun, 10 Feb 2008 16:48:54 +0000 |
| Subject: | note 80996 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135999@lists.php.net to get a copy of this message | ||
Needed a method to cut text without cutting in middle of words, so made this little function to
iterate back until a whitespace is found, and then cut the text from there.
function cutText($string, $length) {
while ($string{$length} != " ") {
$length--;
}
return substr($string, 0, $length);
}
----
Server IP: 87.54.44.10
Probable Submitter: 85.24.88.162
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/80996
Del: integrated -- https://master.php.net/note/delete/80996/integrated
Del: useless -- https://master.php.net/note/delete/80996/useless
Del: bad code -- https://master.php.net/note/delete/80996/bad+code
Del: spam -- https://master.php.net/note/delete/80996/spam
Del: non-english -- https://master.php.net/note/delete/80996/non-english
Del: in docs -- https://master.php.net/note/delete/80996/in+docs
Del: other reasons-- https://master.php.net/note/delete/80996
Reject -- https://master.php.net/note/reject/80996
Search -- https://master.php.net/manage/user-notes.php