/ Published in: PHP

Expand |
Embed | Plain Text
function mysubstr($string,$length,$dots=false,$wc_size=2) { $words = 0; $n = 0; return $string; } while ($n<strlen($string) && $words<$length ) { if($t==9 || $t==10 || (32<=$t && $t<=127)) { $n++; $words ++; } elseif(192<=$t && $t<=223) { $n += 2; if($wc_size == 1){ $words += 1; }else{ $words += 2; } } elseif(224<=$t && $t<=239) { $n += 3; if($wc_size == 1){ $words += 1; }elseif($wc_size == 2){ $words += 2; }else{ $words += 3; } } else { $n++; $words ++; } } $wordscut .= '...'; } return $wordscut; }
You need to login to post a comment.