RT is used to find a function to intercept string in both Chinese and English. substr (), mb_substr (), and iconv_substr () are not very powerful. the user-defined functions released on the Internet have also tried some, no easy to use .! In fact, my main purpose is to cut out several lines of the word length is exactly the same... RT is used to find a function to intercept string in both Chinese and English. substr (), mb_substr (), and iconv_substr () are not very powerful. the user-defined functions released on the Internet have also tried some, no easy-to-use. =!
In fact, my main purpose is to cut out several lines of words with the same length, so please try again ~
Supplement:
The following is the code I used for testing. it seems that the first and second answers have garbled characters ~
PS: If you want to answer a question, you can first test the small text in my section, and then submit the answer ~
';}
Reply content:
RT is used to find a function to intercept string in both Chinese and English. substr (), mb_substr (), and iconv_substr () are not very powerful. the user-defined functions released on the Internet have also tried some, no easy-to-use. =!
In fact, my main purpose is to cut out several lines of words with the same length, so please try again ~
Supplement:
The following is the code I used for testing. it seems that the first and second answers have garbled characters ~
PS: If you want to answer a question, you can first test the small text in my section, and then submit the answer ~
';}
I think what you need ismb_strimwidth
This function, let's look at its definition http://cn2.php.net/manual/en/function...
I used a disgusting solution. Assume that your string is UTF-8 encoded, you need to convert it to gbk.
$gbk_str = iconv('UTF-8', 'GBK', $raw);
Next, substr truncates the $ gbk_str. the gbk-encoded Chinese character is two bytes, and the English word is one, so it is just right.