This article has compiled some common functions in PHP strings. Come and collect them. I hope it will be helpful to you!
String length
String position
strrpos() function finds the last occurrence of a string in another string
strtipos() function finds the last occurrence of a string in another string The position of the last occurrence of a string in another string (not case sensitive)
strpos() function finds the position of the first occurrence of a string in another string
stripos() function finds the first occurrence of a string in another string (not case sensitive)
String interception
String splitting
#The output is an array
- ##explode(separator,string,limit) splits the string
- split(pattern,string,limit) split string
##String comparison
strcmp() function compares two strings #case sensitive strcasecmp() compares two strings #not case sensitive
The strnatcmp() function uses a "natural" algorithm to compare two strings strncmp() is binary safe and case-sensitive.
String ASCII
chr() function returns the character from the specified ASCII value. #ord() function returns the ASCII value of the first character of a string.
String MD5 operation
md5() function calculates the MD5 hash of a string. The md5() function uses RSA data security, including the MD5 message digest algorithm.
String output
echo() print( )#Output one or more strings, the return value is always 1 print_r() var_dump()#Display one or more Structural information of an expression, including the type and value of the expression
The string is trimmed with spaces
trim( ) function to delete the spaces at both ends of the string ltrim() function to delete the spaces on the left side of the string rtrim() function to delete the spaces on the right side of the string
String replacement
##strstr() function#Case sensitive
-
str_replace() function#case-sensitive
-
sunst_replace() function#case-sensitive
-
Recommended study:《
PHP video tutorial
》
The above is the detailed content of Organize and summarize some commonly used functions in PHP strings (collection). For more information, please follow other related articles on the PHP Chinese website!