This article analyzes the use of LTrim and RTrim in PHP to remove the left and right spaces and special characters. Share to everyone for your reference, specific as follows:
The definition of LTrim in PHP is as follows:
LTrim (String,charlist)
Parameter description:
String required. Specify the string to check.
Charlist
Optional. Specify which characters to remove from the string. If this argument is omitted, all of the following characters are removed:
"" "-NULL
"\ T"-tab
"\ n"-line Wrap
"\X0B"-Vertical tab
"\ r"-Carriage return
""-Space
Second, the PHP RTrim definition as follows:
RTrim (String,charlist)
The parameter description is as follows:
String required. Specify the string to check.
Charlist
Optional. Specify which characters to remove from the string. If omitted, all of the following characters are removed:
"" "-NULL
"\ T"-tab
"\ n"-line Wrap
"\X0B"-Vertical tab
"\ r"-Carriage return
""-Space
Three, the usage example is as follows:
<?php
$str = "(: @_@ Yun-Habitat community to provide a large number of excellent scripts and materials for readers to download \ n \ @_@:) ";
Echo LTrim ($STR);
echo "<br>";
Echo LTrim ($str, "(: @_@");
echo "<br/>";
echo RTrim ($STR);
echo "<br>";
Echo RTrim ($str, "@_@:) ");
? >
The results of the operation are as follows:
(: @_@ Cloud Communities provide a wealth of excellent scripts and materials for readers to download @_@:)
Cloud Communities provide a wealth of excellent scripts and materials for readers to download @_@:)
(: @_@ Cloud Communities provide a wealth of excellent scripts and materials for readers to download @_@:)
(: @_@ The cloud-dwelling community provides a wealth of good scripts and materials for readers to download
I hope this article will help you with the PHP program design.