php has a large number of built-in string manipulation functions, such as php implode, explode, etc. To intercept strings in php, you can use the substr and mb_substr functions.
phpsubstr syntax
1 |
|
Parameters
1 2 3 |
|
For example
1 2 3 4 5 6 7 8 9 10 |
|
Careful children may have discovered that substr in $str9 returns � �Hello hello hello, there are Chinese garbled characters appearing.
Substr is often used in PHP to intercept strings, but when we use it to intercept Chinese characters, garbled characters will occur. At this time, we need to use another
One function, mb_substr, now the problem of garbled characters is solved.
The above is the detailed content of How to intercept string in php. For more information, please follow other related articles on the PHP Chinese website!