Every time you encounter a problem, you can solve it. When you solve the problem, you will find that you have been making progress ''''
Every time you encounter a problem, you can solve it.
When you solve the problem, you will find that you have been making progress ''''
Soon after learning php, I liked this language. Perfect.
Today, we have encountered a garbled problem. This type of problem should be universally applied to a smarty template loyal person.
I personally think that smarty and php are almost perfect combinations.
The solution is as follows:
The smarty template intercepts several garbled characters behind the string.
Modify the file modifier_truncate.php
Function smarty_modifier_truncatey ($ string, $ length = 80, $ etc = '...', $ count_words = true ){
Mb_internal_encoding ("UTF-8 ");
If ($ length = 0) return '';
If (strlen ($ string) <= $ length) return $ string;
Preg_match_all ("/[x01-x7f] | [xc2-xdf] [x80-xbf] | xe0 [xa0-xbf] [x80-xbf] | [xe1-xef] [x80-xbf] [x80-xbf] | xf0 [x90-xbf] [x80-xbf] [x80-xbf] | [xf1-xf7] [x80-xbf] [x80-xbf] [x80-xbf]/", $ string, $ info );
If ($ count_words ){
$ J = 0;
For ($ I = 0; $ I $ Wordscut. = $ info [0] [$ I];
If (ord ($ info [0] [$ I]) >= 128 ){
$ J = $ j + 2;
} Else {
$ J = $ j + 1;
}
If ($ j >=$ length ){
Return $ wordscut. $ etc;
}
}
Return join ('', $ info [0]);
}
Return join ("", array_slice ($ info [0], 0, $ length). $ etc;
}
Read {$ xnews [t]. title | truncate: 14}
That's simple '''