84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
如何讓他超過字數再點點點?以下是我寫的假象:
mb_substr("1234567890",0,5,"utf-8");echo '...';
此時會變成12345...這沒問題
但是當沒有超過時也會顯示點點點
mb_substr("1234567890",0,15,"utf-8");echo '...';
1234567890...
網上查的mb_substr函數都只有介紹顯示指定的字數但我沒有找到怎麼樣設條件..就是超過我設定的顯示字數再點點點
人生最曼妙的风景,竟是内心的淡定与从容!
加个判断吧
$text = '123456'; $charLength = 10; //字符串长度 $content = mb_strlen($text, 'UTF-8') <= $charLength ? $text : mb_substr($text, 0,$charLength,'UTF-8') . '...';
只能自己加个判断
function my_substr($str, $start = 0, $length = 0, $encoding = 'utf-8') { return (mb_strlen($str) >= ($length - $start)) ? (mb_substr($str, $start, $length, $encoding).'...') : $str; }
加个判断吧
只能自己加个判断