Regular expressions
1. Replace "/\d/", "#", $str: Regular expression \d number, replace with #, string
$str = "2hello 5li 6lei";
Echo preg_replace ("/\d/", "#", $str);
2. Split regular Expression, string
$str = "2hello 5li 6lei";
Var_dump (Preg_split ("/\d/", $str));
3. Match all strings that satisfy the regular
$str = "2hello 5li 6lei";
Preg_match_all ("/\d", $str, $arr); Regular expressions, defined strings, arrays
Var_dump ($arr); Match a string that satisfies all the regular strings
4. Match the first string that satisfies a regular
$str = "2hello 5li 6lei";
Preg_match ("/\d/", $str, $arr);
Var_dump ($arr);
Generate random numbers
echo rand ();
echo "<br>";
echo rand (0,10);
echo "<br>";
Get current time
echo Time ();
echo "<br>";
Format the display of time
echo Date ("Y-m-d h:i:s", "1506494423");
echo "<br>";
Echo strtotime ("2017-09-27 14:40:23");
String functions
Go string length
$str 1= "as";
$str 2= "ABCDECDCD";
Compare length ASC Code
Var_dump (strcmp ($str 2, $str 1));
Display length
echo strlen ($STR);
Splitting a string
Split ()--js
echo "<br>";
Var_dump (Explode (' B ', $str 2));
Link character
echo Implode (' | ', ["a", "B", "C"]);
Replace string lookup substitution
Echo str_replace ("CD", "CD", $str 2);
Specify location substitution
Echo Substr_replace ($str 2, "xxx", 0, 3);
Intercept string
Echo substr ($str 2,1,3);
PHP Regular Expression Application