1. Collation of Strings: Chop (), Itrim (), Trim ()
The trim () function is used to organize user input data, as shown below:
$name =trim ($name);
$email =trim ($email);
The Tirm () function can remove spaces from the start and end of a string and return the resulting string. By default, the line break (n) Carriage return (R) horizontal (t) and vertical tab (X0B) string end symbols () and spaces are stripped.
The following is from the manual
Without the second parameter, RTrim () to the strip these characters:
* "" (ASCII (0x20)), an ordinary space.
* "T" (ASCII 9 (0x09)), tab.
* "N" (ASCII (0x0A)), a new line (line feed).
* "R" (ASCII (0x0D)), a carriage return.
* "" (ASCII 0 (0x00)), the Nul-byte.
* "x0b" (ASCII (0x0b)), a vertical tab
Example#1 Usage Example of RTrim ()
<?php
$text = "Ttthese are a few words:) ... ";
$binary = "X09example stringx0a";
$hello = "Hello World";
Var_dump ($text, $binary, $hello);
Print "n";
$trimmed = RTrim ($text);
Var_dump ($trimmed);
$trimmed = RTrim ($text, "t.");
Var_dump ($trimmed);
$trimmed = RTrim ($hello, "Hdle");
Var_dump ($trimmed);
Trim the ASCII control characters in the end of $binary
(from 0 to inclusive)
$clean = RTrim ($binary, "x00.") x1f ");
Var_dump ($clean);
?>
The example above will output:
"These are a few words:) ... "
String (Example) string
"
String (one) "Hello World"
"These are a few words:) ..."
String "These are a few words:)"
String (9) "Hello Wor"
String "Example string"
function explode () implode () join ()
explode-use a string to split another string
Ordering of Strings strcmp () strcasecmp () strnatcmp ()
Find a string in a string strstr () STRCHR () strrchr () Stristr ()
Too much, read the handbook slowly.