note 64089 rejected from function.substr by nlopess
| From: | nlopess@php.net | Date: | Sun, 16 Apr 2006 12:51:40 +0000 |
| Subject: | note 64089 rejected from function.substr by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108274@lists.php.net to get a copy of this message | ||
Note Submitter: o70vd at yahoo dot com
----
This function sets long string to short string.. for example.. $str = "blah blah blah blah blah
blah blah blah blah blah"
then you want to limit you string to 30"->setStringLimit($srt, 0, 30)<- output would is
"blah blah blah blah blah blah..." . hehe. Don't really trust the code,
Is there any other function that to do same way?. Please teach me. Thankx.Just wanted to test if my
code is enough!... tnx.
function setStringLimit($str, $start, $until){
return (strlen($str) > $until) ? (substr((substr($str, $start, $until)), $start,
(strrpos(substr($str, $start, $until), " ")) )."...") : ($str);
}