1. Find character position function:
strpos ($str,search,[int]): Find the first position of search in $str starting from int;
stripos ($str,search,[int]): The function returns the position of the first occurrence of a string in another string. This function is not case sensitive
strrpos ($str,search,[int]): Find the last occurrence of search in $str starting from int
2. Extract sub-character function (double bytes)
submit ($str,int start[,int length]): Extract [length-length string] starting from the strat position in $str.
strstr ($str1,$str2): Search $str2 from $str1 (the first position) and intercept the string starting from it to the end; if not, return FALSE.
stristr() has the same function as strstr, except that it is not case-sensitive.
strrchr() returns from the last character searched; use: to get the file name in the path
3. Replace string
str_replace (search,replace,$str): Find search from $str and replace
with replacestr_irreplace (search,replace,$str): Not case sensitive
strtr ($str,search,replace): replace in this function cannot be "";
substr_replace ($str,$rep,$start[,length]) $str original string, $rep new string after replacement, $start starting position, $length replacement length, this item Optional
4. Character length
int strlen($str)
5. Comparison character function
strcmp ($str1,$str2): $str1>=<$str2 are positive 1, 0, -1 respectively (string comparison)
strcasecmp() Same as above (not case sensitive)
strnatcmp("4","14") compares strings in natural order
strnatcasecmp() Same as above, (case sensitive)
6. Split into array functions
str_split ($str,len): Split $str according to the length of len and return the array
split (search,$str[,int]): Split $str according to the search character and return the array int how many times it is divided, and the rest will not be divided
explode (search,$str[,int])
7. Remove spaces: ltrim, rtrim, trim
8. Add space function
chunk_split ($str,2); Press 2 characters into the $str character to add a space;
9, chr, ord -- return the specified character or ascii
10. Functions related to HTML code
nl2br(): Convert n to
.
strip_tags($str[,' ']): Remove HTML and PHP tags. All HTML and PHP code in $str will be removed, and the optional parameters are html and PHP codes that will retain the code written by the optional parameters. For example: echo strip_tags($text, ' ');
htmlspecialchars($str[, parameter]): The normal output of the page HTML code parameters is the conversion method
11. Character case conversion function
strtolower($str) converts the string to lowercase
strtoupper($str) Convert string to uppercase
ucfirst($str) Converts the first character of the function to uppercase
ucwords($str) Converts the first letter of each word to uppercase
12. Database related functions
Addslashes($str): Convert single quotes ('), double quotes ("), backslashes () and NUL strings in str to ',",\.
Magic_quotes_gpc = On Automatically escape the content of get post cookie
Get_magic_quotes_gpc() Check whether magic_quotes_gpc is turned on
When magic_quotes_gpc=On, the function get_magic_quotes_gpc() will return 1
When magic_quotes_gpc=Off, the function get_magic_quotes_gpc() will return 0
Stripslashes() removes backslashes from strings