<BR>//所谓断字 (word break),即一个单词可在转行时断开的地方。这一函数将在断字处截断字符串。 <BR>// Please acknowledge use of this code by including this header. <BR>function myTruncate($string, $limit, $break=".", $pad="...") { <BR>// return with no change if string is shorter than $limit <BR>if(strlen($string) <= $limit) <BR>return $string; <BR>// is $break present between $limit and the end of the string? <BR>if(false !== ($breakpoint = strpos($string, $break, $limit))) { <BR>if($breakpoint < strlen($string) - 1) { <BR>$string = substr($string, 0, $breakpoint) . $pad; <BR>} <BR>} <BR>return $string; <BR>} <BR>/***** Example ****/ <BR>$short_<em>¥本文来%源[email protected]搞@^&代*@码)网5</em><strong>搞gaodaima代码</strong>string=myTruncate($long_string, 100, ' '); <BR>