In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to intercept Chinese strings from several bits by php". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to intercept Chinese strings from several digits in php" can help you solve the problem.
In php, you can use the mb_substr () function to intercept a Chinese string from the specified bit. This function can intercept a substring of specified length from a specified position of a string and set the character encoding; syntax "mb_substr (specified string, intercepted start position, intercepted length, character encoding)".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
When dealing with strings, sometimes we need to intercept strings. In PHP, intercepting strings can be achieved through PHP's predefined functions substr () and mb_substr ()
Among them, the substr () function is not very friendly to Chinese processing, while the mb_substr () function is used to intercept Chinese strings.
The mb_substr () function can intercept a specified part from a string. Unlike the substr () function, the mb_substr () function is valid not only for English characters, but also for Chinese characters. Its syntax format is as follows:
Mb_substr (string $str, int $start [, int $length = NULL [, string $encoding = mb_internal_encoding ()]]): the string parameter is required to describe str. Fetch the substring from the string. Start
Necessary. Specifies where to start the string.
Positive number-starts at the specified position of the string
Negative number-starts at the specified position at the end of the string
0-starts at the first character in the string
Length is optional. Specifies the length of the string to return. The default is until the end of the string.
Positive number-returns from the location where the start parameter is located
Negative number-returns from the end of the string
Encoding is optional. Character encoding. If omitted, internal character encoding is used.
Return value: returns the extracted part of the string, or FALSE if it fails, or an empty string.
Example: use the mb_substr () function to intercept a Chinese string of a specified length.
This is the end of the introduction on "how to intercept Chinese strings from the first bit of php". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.