This is just an ordinary essay.

Needless to say, recently involved in the development of the company’s PHP related business, encountered a string truncation problem. The biggest characteristic of these strings is the mixture of Chinese/English/numbers/punctuation marks. Neither conventional SUBSTR nor MB_SUBSTR can intercept satisfactory results. Unfortunately, I have read a lot of tool classes in symfony before development and directly adopted the method MBSTRING :: SUBSTR to intercept strings. Save time and effort.

I have also browsed a lot of methods on interception given on the Internet, such as Chinese judgment before interception, which is particularly troublesome. In addition, there are always loopholes when the current business processing effect is not good. I have had a rough look at the methods of this class, and it is very comprehensive. It is a good tool class.

The class is as follows

Symfony mbstring.php class related source code