-------------------------------------------------- -------------
Function Msubstr ($ STR, $ START, $ LEN) {
$ Strlen = $ start $ LEN;
For ($ I = 0; $ I <$ Strlen; $ I ) {
IF (Substr ($ Str, $ I, 1)> 0xA0) {
$ Tmpstr. = Substr ($ STR, $ I, 2);
$ i ;
Else
$ Tmpstr. = SUBSTR ($ STR, $ I, 1);
}
Return $ TMPSTR;
}
-------------------------------------
PHP
$ Str = "This character is long, ^ _ ^";
$ Short_STR = Showsh ($ STR, 4); // Intercept 4 Chinese characters in front, the result is: this character ...
Echo "$ Short_STR";
Function Csubstr ($ STR, $ START, $ LEN)
{
$ Strlen = Strlen ($ STR);
$ clen = 0;
For ($ I = 0; $ I <$ Strlen; $ i , $ Clen )
{
IF ($ clen> = $ start $ g)
Break;
IF (Substr ($ Str, $ I, 1)> 0xA0)
{
IF ($ clen> = $ s)
$ Tmpstr. = Substr ($ STR, $ I, 2);
$ i ;
}
Else
{
IF ($ clen> = $ s)
$ Tmpstr. = SUBSTR ($ STR, $ I, 1);
}
}
Return $ TMPSTR;
}
Function Showsh ($ STR, $ LEN)
{
$ TEMPSTR = CSUBSTR ($ STR, 0, $ LEN);
IF ($ STR <> $ TEMPSTR)
$ Tempstr. = "..."; // What is the end of the end, modify it here.
Return $ TEMPSTR;
}