Description of phptrim () function instances and trim instances. The phptrim () function example explains how to remove white spaces or other pre-defined characters on both sides of a string from the phptrim () function. This article introduces phptrim () to coders () php trim () function example for function users and trim example
The php trim () function removes white spaces or other pre-defined characters on both sides of the string. This article introduces the usage and examples of the php trim () function to coders, for more information, see.
Definition and usage
The trim () function removes spaces or other predefined characters on both sides of a string.
Related functions:
- Ltrim ()-removes white spaces or other predefined characters from the left of the string.
- Rtrim ()-removes spaces or other predefined characters from the right of the string
Syntax
trim(string,charlist)
| Parameters |
Description |
| String |
Required. Specifies the string to be checked. |
| Charlist |
Optional. Specifies which characters are deleted from the string. If omitted, all the following characters are removed:
- "\ 0"-NULL
- "\ T"-tab
- "\ N"-line feed
- "\ X0B"-vertical tab
- "\ R"-Press enter
- ""-Space
|
Technical details
| Return value: |
Returns the modified string. |
| PHP version: |
4 + |
| Update Log: |
In PHP 4.1CharlistParameters. |
Instance
Remove spaces on both sides of the string:
"; Echo" use trim: ". trim ($ str);?>
Online operation
The HTML output of the above code is as follows (check the source code ):
Do not use trim: Hello World!
Use trim: Hello World!
The browser output of the above code is as follows:
Do not use trim: Hello World! Use trim: Hello World!
Address: http://www.manongjc.com/article/827.html
Related reading:
The php trim () function removes spaces or other predefined characters on both sides of the string.
The php rtrim () function removes the white space or other predefined characters on the right of the string.
The php trim () function removes spaces or other predefined characters on both sides of the string.
Http://www.bkjia.com/PHPjc/1126525.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1126525.htmlTechArticlephp trim () function example, trim example explains php trim () function removes white spaces or other pre-defined characters on both sides of the string, this article introduces the php trim () function user...