FunctionSubTitle ($ String, $ Length) {if (mb_strwidth ($ String, & amp; #39; UTF8 & amp; #39;) & lt; $ Length) {return $ String;} else {$ I0; $ len_word0; while ($ len_word & lt; $ Length) {$ Str
Function SubTitle ($ String, $ Length ){
If (mb_strwidth ($ String, 'utf8') <= $ Length ){
Return $ String;
} Else {
$ I = 0;
$ Len_word = 0;
While ($ len_word <$ Length ){
$ StringTMP = substr ($ String, $ I, 1 );
If (ord ($ StringTMP) & gt; = 224 ){
$ StringTMP = substr ($ String, $ I, 3 );
$ I = $ I + 3;
$ Len_word = $ len_word + 2;
} Elseif (ord ($ StringTMP)> = 192 ){
$ StringTMP = substr ($ String, $ I, 2 );
$ I = $ I + 2;
$ Len_word = $ len_word + 2;
} Else {
$ I = $ I + 1;
$ Len_word = $ len_word + 1;
}
$ StringLast [] = $ StringTMP;
}
/* Raywang edit it for dirk for (es/index. php )*/
If (is_array ($ StringLast )&&! Empty ($ StringLast )){
$ StringLast = implode ("", $ StringLast );
$ StringLast. = "...";
}
Return $ StringLast;
}
}