Home  >  Article  >  Backend Development  >  Implementation of trim function code in php_PHP tutorial

Implementation of trim function code in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:56:07909browse

Remove the spaces before and after.

Suppose there is a string "ddd dd d", which becomes "ddd dd d" after Trim().

As above, you can remove the extra spaces on both sides (including the formatting) symbol), 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 been in contact with ASP, you will naturally use it.
Usage It is relatively simple. Add the following to the variable where you want to remove spaces:
echo trim($variable);
?>

Generally used for user password processing middle.

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:
"



http://www.bkjia.com/PHPjc/318090.html

www.bkjia.comtrue

http: //www.bkjia.com/PHPjc/318090.htmlTechArticleRemove the leading and trailing spaces. Suppose there is a string "dddddd", which becomes "dddddd" after Trim(). As above, you can remove extra spaces (including tab characters) on both sides, but you cannot remove the spaces in the middle...




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn