In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to intercept strings from the first bit of php, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Intercept methods: 1, using the substr () function, syntax "substr (string, intercepting the starting position of the string, intercepting the length of the string)"; 2, using the mb_substr () function, syntax "mb_substr (string, intercepting the starting position of the string, intercepting the length of the string, character encoding)".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, to intercept a string from a specified location, you can use the substr () and mb_substr () functions.
Both the substr () and mb_substr () functions can intercept strings. The only difference between them is the handling of Chinese characters. Let's take a look at these two functions.
The substr () function intercepts a string
The substr () function can intercept characters of a certain length from a specified position in a string.
Example:
Substr () function to deal with English is not any problem, but in the development we often deal with more Chinese characters, substr () function can also deal with Chinese, but not very perfect. So how to intercept Chinese characters? You can use the mb_substr () function.
The mb_substr () function intercepts 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.
Use skills:
Use the mb_substr () function to intercept a string of specified length, using "..." for the excess. Instead.
The above is all the content of the article "how to intercept strings from php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.