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
<?php
$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 () make \ n convert to <br>
strip_tags ($str, [' <p> ']) remove HTML and PHP tags
such as: Echo Strip_tags ($text, ' <br><p> ')
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
PHP commonly used string processing functions: