Ec (2); php character truncation function functionsub_str ($ title, $ lengh) {& nbsp; if (strlen ($ title) & gt; $ lengh) & nbsp; {& nbsp; $ pp2; & nbsp; $ lenstrlen ($ title); & nbsp; if ($ len % 2 & lt; & gt; 0) & nbsp; {$ pp1 script ec (2); script
Php character truncation Function
Function sub_str ($ title, $ lengh ){
If (strlen ($ title)> $ lengh)
{
$ Pp = 2;
$ Len = strlen ($ title );
If ($ len % 2 <> 0)
{$ Pp = 1 ;}
$ Title = substr ($ title, 0, $ lengh-$ pp );
$ Title = $ title .'... ';
}
Return $ title;
}
// ---------------------------------------- Character truncation function 2
Function sub ($ Modi_Str, $ start, $ length, $ mode = false ){
$ N = 0;
For ($ I = 0; $ I <$ start; $ I ++ ){
If (ord (substr ($ Modi_Str, $ I, 1)> 0xa0 ){
If ($ mode ){
$ Start ++;
$ I ++;
}
$ N ++;
}
}
If (! $ Mode) $ start = $ start + $ n % 2;
$ The_length = $ start + $ length;
For ($ I = $ start; $ I <$ The_length; $ I ++ ){
If (ord (substr ($ Modi_Str, $ I, 1)> 0xa0 ){
$ The_Str. = substr ($ Modi_Str, $ I, 2 );
$ I ++;
If ($ mode) $ The_length ++;
} Else {
$ The_Str. = substr ($ Modi_Str, $ I, 1 );
}
}
Return $ The_Str;
}