Tag: http is the DIV technology that will share the SRC function. com Sub
Today encountered a pit, left and right to debug the pit of my face, when we intercept a string, usually the first thought is the substr () function, but if it is a Chinese + numeric string, then the use of substr interception will appear garbled problem, This is because substr will be the Chinese according to each character three byte interception, so the interception of Chinese is not applicable, another method is to use the MB_SUBSTR () or mb_strcut () function to intercept, and set the interception of the encoding format of ' Utf-8 ', Using these two functions requires opening the Php_mbstring.dll extension in the php.ini, removing the front, and then restarting PHP-FPM,
$string = "Radisson Blu Plaza Hotel, No. No. 968, Xiacheng Road, preoccupy";
I first used the MB_SUBSTR () function, but did not solve my problem, some do not garbled, some or garbled, and do not know the online those who say with this function can solve the problem is not encountered--!
Echo mb_substr ($string, 0,40, ' utf-8 ');
Finally I used the mb_strcut () function, and its usage is the same as MB_SUBSTR (), which solves the problem:
Mb_strcut ($string, 0,40, ' utf-8 ');
Solution for PHP to intercept string after garbled