In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use the php string comparison function, which is very detailed and has a certain reference value. Friends who are interested must finish it!
1.strcmp () function: this function compares strings and is case-sensitive when comparing.
Declaration: strcmp (string str1,string str2)
This function compares the two passed string arguments and returns 0 if the two strings are exactly the same, a positive number if str1 follows str2 in dictionary order, and a negative number if str1 is less than str2.
Example:
Output result:
$an is greater than $b
2.strcasecmp (): this function is basically the same as the strcmp function, but when compared, it is not case-sensitive.
Example:
Output result:
$val1 is the same as $val2 (ignore the case of the string)
3. Natural sort strnatcmp (): this function is basically the same as the strcmp function, but the principle of comparison is different. This function is not arranged in dictionary order, but compares strings in "natural sort". The so-called natural sorting is to sort according to people's habits, such as the strcmp function to sort, "4" will be greater than "14", but in reality, the number "14" is greater than "4", so the strnatcmp function is compared according to the latter.
4.strnatcasecmp (): this function is the same as the strcasecmp function, except that it is not case-sensitive
The above is all the contents of the article "how to use the php string comparison function". Thank you for reading! Hope to share the content to help you, more related 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.