1 Find the character position function:
Strpos ($str, $seach, [int]); Find the first position of search in $str starting with int;
Stripos ($str, $seach, [int]); The function returns the position of the first occurrence of the string in another string. This function is not sensitive to case
Strrpos ($str, Search,[int]): Find where the last occurrence of search in $STR starts with int
Strripos ($str, Search,[int]): Ibid., this function is insensitive to case
2. Functions to extract substrings
SUBSTR ($str, int start,[int Len])
Strstr ($str 1,str2)
Stristr () function with strstr, just case insensitive
STRRCHR () prompt returned from the last word searched; use: Fetch the file name in the path
3. PHP string function for replacing strings
Str_replace (search,replace,source) Find search Replace with Replace in source
Str_ireplace (Search,replace, $str): ibid., this function is insensitive to case
STRTR ($str, $from, $to) The function returns a copy of Str and converts the character specified in the From to the corresponding character in to
$trans = Array ("Hello" = "hi", "hi" = "Hello");
echo strtr ("Hi all, I said hello", $trans);
?>
Substr_replace ($Str, $rep, $start [, Length]): $str The original string, $rep the new string after replacement, $start the starting position, $length the length of the replacement, which is optional
4. Character length
int strlen ($STR)
5. Compare character functions
int strcmp ($str 1, $str 2) $str 1>=< $str 2 are positive 1,0,-1 (string comparison)
STRCASECMP () ignoring case (IBID.)
STRNATCMP ("8", "18") compare strings by natural sort
STRNATCASECMP ()
6. PHP String functions for splitting into groups
Str_split ($str, Len)
Split (search, $STR, [int])
Explode (search, $str, [int]) splits the $STR by the search character return array int is split several times, the back will not be split
7, remove the space:
LTrim () RTrim () trim ()
8, add the Space function
Chunk_split ($STR, 2) Add a space to the $STR character by 2 characters;
9, CHR, ord--returns the specified character or ASCII
10. HTML code related functions
NL2BR () makes \ n convert to
Strip_tags ($STR, ['
']) to remove HTML and PHP tags
such as: Echo Strip_tags ($text, '
')
Htmlspecialchars ($str [, var])
11. Character-case-conversion PHP String functions
Strolower (str)
Stroupper (str)
Ucfirst (str) converts the first character of a function to uppercase
Ucwords (str) converts the first letter of each word to uppercase
12. Database-related PHP string functions
Addslashes (str) converts the single quotation mark ('), double quotation mark ("), backslash (\), and nul string in str to \ ', \ ', \ \.
MAGIC_QUOTES_GPC = On: Automatically escapes the contents of the Get,post,cookie
GET_MAGIC_QUOTES_GPC (): Detects if MAGIC_QUOTES_GPC is turned on
Stripslashes (): Remove backslash from string