Home > Backend Development > PHP Tutorial > trim function implementation trim function code in php

trim function implementation trim function code in php

WBOY
Release: 2016-07-29 08:36:49
Original
1170 people have browsed it

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.


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template