PHP string Processing
PHP's string handling capabilities are very powerful, including:
String output
Echo (): Output one or more strings
Print (): Output a string
printf (): Output formatted string
String removal
Trim (): Removes special symbols such as String end and end blanks, or sequences of specified characters
LTrim (): Remove special symbols such as the first whitespace of the string or specify a sequence of characters
RTrim (): Remove special symbols such as string trailing blanks or specify character sequences
Chop (): With RTrim ()
String connection
Implode (): Use characters to combine the contents of an array into a single string
Join (): Same as implode ()
String segmentation
Explode (): Splitting another string with one string
Str_split (): Splitting a string into an array
String fetching
SUBSTR (): Get a portion of it from a string
Strstr (): Finds the position of the first occurrence of a string in another string and returns all characters from that position to the end of the string
SUBCHR (): With Strstr ()
STRRCHR (): Finds the last occurrence of a string in another string and returns all characters from that position to the end of the string
String substitution
Substr_replace (): Replace part of a string with another string
Str_replace (): Replaces other characters in a string with one string
String calculation
Strlen (): Gets the length of the string
Strpos (): Position the first occurrence of a string
Strrpos (): Position the last occurrence of the string
String XHTML formatted display
NL2BR (): Converts line break N to XHTML line break <br/>
Htmlspecialchars (): Convert some special characters to HTML entities
Htmlspecialchars_decode (): Convert some HTML entities to special characters, htmlspecialchars () inverse function
String Storage (escaped)
Addslashes (): Adds an escape character to a special character.
Stripslashes (): Inverse function of addslashes ().
Tip: If you need more complex string handling, you can use regular expressions, see PHP Regular expressions.
PHP string Processing