Commonly used PHP functions:
String processing function:
Powerful features:
1. Other types of data used in string processing functions will automatically convert them into strings before processing
2. You can use the string as an array, as a collection of characters, as: $ Str = "Lijian"; Echo $ Str [1]; but this will make people mistakenly think that it is an array, so it usually writes: echo $str{1};
takes out the first two characters: echo $str[0].$str[1]; A new format string
Trim (); default is deleting space. Note that the deletion here is not the real deletion
trim ($ str, '0..9.'); There are still spaces
ltrim($str,'1'); delete the number 1 on the left
rtrim($str,'0..9'); . l2br;
htmllentities( ; using Function:
use using natural ordering algorithm
using strnatcmp()strstr(): Distinguish the size Write, return the string starting from the matching place
stristr(): case-insensitive
stripos(): Find the position where the string first appears, case-insensitive
strpos(): Find the string The first occurrence position, case-sensitive
strrpos(): Find the last occurrence position of the string, case-sensitive strripos(): Find the last occurrence position of the string, case-insensitive
substr(): Also If there are other string 子 if you put the numbers in the number, you can automatically convert it into a string, such as: Substr (123456,2,4);
Str_replace (String, String, String): L Str_replace (Array, String, String): Replace multiple of multiple with one
Str_replace (Array, Array, String): Replace multiple
str_ireplace (): Do not distinguish between manuscripts ():::) Convert a string into an array
Implode(): Convert an array into a string
Array function:
What is the difference between array_map();
mysqli_fetch_assoc() and mysqli_fetch_row() and mysqli_fetch_object()?
Using mysqli_fetch_assoc() and mysqli_fetch_row() both return the query results into an array, both return the first row and then move the pointer down one row.
Difference: mysqli_fetch_assoc() uses keyword index to obtain the value. For example:
$row = $result->fetch_assoc();
echo $row['username'];
But mysqli_fetch_row() uses a numeric index to obtain the value. For example:
$row = $result->fetch_row();
echo $row[0];//Note: "0" means the first field in the table (that is, username is the first field in the table) a field).
There is also another function: mysqli_fetch_object() to get a row back into an object, and then get the value through a class, for example:
$row = $result->fetch_object();
echo $row- >username;
The above has introduced a detailed explanation of commonly used functions in PHP, including relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.