Remove the spaces before and after.
Suppose there is a string "ddd dd d", which becomes "ddd dd d" after Trim().
As above, the extra spaces on both sides (including tab characters) can be removed, but the spaces in the middle cannot be removed .
The trim() function in PHP is used the same as the trim() function in ASP. If you have come into contact with ASP, you will naturally use it.
The usage is relatively simple. Add the following to the variable where you want to remove spaces:
echo trim($variable);
?>
Generally used in user password processing.
Definition and Usage
trim() function removes whitespace characters and other predefined characters from both ends of a string.
Syntax
trim(string,charlist) Parameter Description
string Required. Specifies the string to check.
charlist optional. Specifies the string to be converted. If this parameter is omitted, all following characters are removed:
"
The above introduces the trim function code in PHP, including the trim function content. I hope it will be helpful to friends who are interested in PHP tutorials.