PHP trim () Function example explained, trim example explained
The PHP trim () function removes whitespace characters or other predefined characters on either side of the string, and this article introduces the usage and examples of the PHP trim () function to the code farmer, which is of interest to the code farmer.
Definition and usage
The trim () function removes white space characters or other predefined characters on either side of the string.
Related functions:
- LTrim ()-removes white space characters or other predefined characters to the left of the string
- RTrim ()-Remove whitespace characters or other predefined characters to the right of the string
Grammar
Trim (string,charlist)
| Parameters |
Description |
| String |
Necessary. Specifies the string to check. |
| Charlist |
Optional. Specifies which characters are removed from the string. If omitted, all of the following characters will be removed:
- "+"-NULL
- "\ T"-tab
- "\ n"-line break
- "\X0B"-Vertical tab
- "\ r"-Enter
- ""-Space
|
Technical details
| return value: |
Returns the modified string |
| PHP version: |
4 + |
| Update log: |
In PHP 4.1, the charlist parameter has been added. |
Instance
To remove spaces on either side of a string:
"; echo" using Trim: ". Trim ($STR);? >
Run online
The HTML output of the above code is as follows (see source code):
Do not use Trim:
Using Trim:hello world!
The browser output of the above code is as follows:
Use Trim:hello world! without using Trim:hello world!
Original address: http://www.manongjc.com/article/827.html
Related reading:
The PHP trim () function removes white space characters or other predefined characters on either side of the string
The PHP RTrim () function removes white space characters or other predefined characters to the right of the string
The PHP trim () function removes white space characters or other predefined characters on either side of the string
http://www.bkjia.com/PHPjc/1126525.html www.bkjia.com true http://www.bkjia.com/PHPjc/1126525.html techarticle the PHP trim () Function example explains that the trim instance explains that the PHP trim () function removes whitespace characters or other predefined characters on either side of the string, and this article introduces the user of the PHP trim () function to the code farm ...