note 46917 deleted from ref.strings by derick
| From: | derick@php.net | Date: | Wed, 09 Feb 2005 18:11:07 +0000 |
| Subject: | note 46917 deleted from ref.strings by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-84740@lists.php.net to get a copy of this message | ||
Note Submitter: [tab!]
----
//
// string strtrmvis(string str, [int maxlen = 64])
//
// truncate a long string to a given maximum length by inserting
// a placeholder in the middle
//
function strtrmvis($str, $maxlen = 64) {
if(strlen($str = chop($str)) > ($maxlen = max($maxlen, 12))) {
$chunklen = ($maxlen / 2);
$str = substr($str, 0, $chunklen - 2) . ".. .." .
substr($str, $chunklen - (2 * $chunklen) + 3, $chunklen);
}
return($str);
}