: This article describes how to remove spaces and special characters between ltrim and rtrim in PHP. For more information about PHP tutorials, see. This article analyzes the usage of ltrim and rtrim in PHP to remove left and right spaces and special characters. We will share this with you for your reference. The details are as follows:
I. Definitions of ltrim in PHP are as follows:
Ltrim (string, charlist)
Parameter description:
String is required. Specifies the string to be checked.
Charlist
Optional. Specifies which characters are deleted from the string. If this parameter is omitted, all the following characters are removed:
"\ 0"-NULL
"\ T"-tab
"\ N"-line feed
"\ X0B"-vertical tab
"\ R"-Press enter
""-Space
2. rtrim in PHP is defined as follows:
Rtrim (string, charlist)
Parameters are described as follows:
String is 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
III. Usage example:
<? Php $ str = "(: @ _ @ this site provides a large number of excellent scripts and materials for readers to download \ n @ _ @:)"; echo ltrim ($ str); echo"
"; Echo ltrim ($ str," (: @ _ @ "); echo"
"; Echo rtrim ($ str); echo"
"; Echo rtrim ($ str," @ _ @:) ");?>
The running result is as follows:
(: @ _ @ This site provides a large number of excellent scripts and materials for readers to download @ _ @:) This site provides a large number of excellent scripts and materials for readers to download @_@:)(: @ _ @ this site provides a large number of excellent scripts and materials for readers to download @ _ @:) (: @ _ @ this site provides a large number of excellent scripts and materials for readers to download
I hope this article will help you with PHP programming.
The above introduces the examples of ltrim and rtrim in PHP to remove left and right spaces and special characters, including some content, and hope to help friends who are interested in PHP tutorials.