note 59159 deleted from function.substr by bobby
| From: | bobby@php.net | Date: | Thu, 14 Sep 2006 17:45:54 +0000 |
| Subject: | note 59159 deleted from function.substr by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-117185@lists.php.net to get a copy of this message | ||
Note Submitter: drifterlrsc at yahoo dot com
----
another function simular to Jays
function myfragment($s,$n) {
$scan=0;
while($scan==0){
if(substr($s,$n,1)==' '){
$scan=1;
}else{
$n++;
}
}
return substr($s,0,$n) . "...";
}
$string='this is some content to be shortened';
echo myfragment($string,15);
will output
this is some content...
goes to the first space after 15 characters.