Help ~~ I have written a function for displaying custom string lengths. the code is as follows: PHPcodefunction_word_num ($ string, $ length) {$ stringtrim ($ string ); if (strlen ($ string) & gt; $ length) {return (mb help ~~ Question about displaying custom length strings
I wrote a function with a custom string length. the code is as follows:
PHP code
Function _ word_num ($ string, $ length) {$ string = trim ($ string); if (strlen ($ string) >$ length) {return (mb_substr ($ string, 0, $ length, "gbk "). "... ") ;}else {return $ string ;}}
The problem is that after using this function, no matter whether the length is consistent or not, "..." is added to all of them for explanation ..
------ Solution --------------------
I also think the code is okay. maybe I think the character string uploaded by the landlord is Chinese, but the landlord needs to know that the strlen in Chinese is twice that in English, pay attention to the length.
If the owner knows it, then I don't know why.
------ Solution --------------------
The code is correct...
------ Solution --------------------
Provide your test data.