PHPString function category, phpstring function. PHPString function classification, phpstring function 1. search for character location function: strpos ($ str, search, [int]): search for the first position of search in $ str starting from int; stripos ($ str, search, [int] PHP String function category, phpstring function
1. search for the character location function:
Strpos ($ str, search, [int]): searches for the first position of search in $ str starting from int;
Stripos ($ str, search, [int]): the position where the string first appears in another string. This function is case insensitive.
Strrpos ($ str, search, [int]): searches for the last position of search in $ str from int
2. extract sub-character functions (dual-byte)
Submit ($ str, int start [, int length]): Extracts [length strings] starting from the strat position in $ str.
Strstr ($ str1, $ str2): Searches for $ str2 from $ str1 (the first position) and truncates the string from the start to the end. if not, FALSE is returned.
Stristr () is the same as strstr, but is case insensitive.
Strrchr () is returned from the last searched character. usage: get the file name in the path
3. replace string
Str_replace (search, replace, $ str): search for search from $ str and replace it with replace.
Str_irreplace (search, replace, $ str): Case insensitive
Strtr ($ str, search, replace): In this function, replace cannot be "";
Substr_replace ($ str, $ rep, $ start [, length]) $ str original string, $ new string after rep replacement, $ start position, $ length replacement length, optional
4. character length
Int strlen ($ str)
5. Comparison of character functions
Strcmp ($ str1, $ str2): $ str1 >=< $ str2 is positive 1, 0,-1 (string comparison)
Strcasecmp () Same as above (case-insensitive)
Strnatcmp ("4", "14") compares strings in natural order
Strnatcasecmp () is the same as above (case sensitive)
6. split into array functions
Str_split ($ str, len): Splits $ str by len length and returns an array.
Split (search, $ str [, int]): Splits $ str by the search character and returns the number of times the array int is split.
Explode (search, $ str [, int])
7. remove spaces: ltrim, rtrim, and trim
8. space function
Chunk_split ($ str, 2); add a space to the $ str string containing 2 characters;
9. chr and ord -- return the specified character or ascii
10. functions related to HTML code
Nl2br (): converts \ n
.
Strip_tags ($ str [,'
']): Removes HTML and PHP tags. In $ str, all HTML and PHP code will be removed. the optional parameters are html and PHP code, which will retain the code written by the optional parameters. For example, echo strip_tags ($ text ,'
');
Htmlspecialchars ($ str [, parameter]): The HTML code parameters output normally on the page are converted.
11. case-insensitive conversion functions
Strtolower ($ str) string to lowercase
Strtoupper ($ str) 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): converts single quotation marks ('), double quotation marks ("), backslash (\), and NUL strings \',\",\\.
Magic_quotes_gpc = On automatically escapes the get post cookie content
Get_magic_quotes_gpc () check whether magic_quotes_gpc is enabled
When magic_quotes_gpc = On, the get_magic_quotes_gpc () function returns 1.
When magic_quotes_gpc = Off, the get_magic_quotes_gpc () function returns 0.
Stripslashes () removes the backslash from the string
Http://www.bkjia.com/PHPjc/989817.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/989817.htmlTechArticlePHP String function classification, phpstring function 1, find character location function: strpos ($ str, search, [int]): find the first position of search in $ str from int; stripos ($ str, search, [int]...