Instances of ltrim(), rtrim() and trim() in php to delete character spaces, ltrimrtrim
The example in this article describes the methods of removing character spaces with ltrim(), rtrim() and trim() in php. Share it with everyone for your reference. The specific analysis is as follows:
The trim function in php cannot automatically delete all spaces like the one in asp. PHP professional provides the rtrim() trim() function. Friends who are interested in this can refer to it.
PHP example code is as follows:
Copy code The code is as follows:
$str="Remove leading and trailing spaces";
echo "The original string in square brackets: [".$str."]
";
echo "Original string length:".strlen($str)."
";
$str1=ltrim($str);
echo "The length after executing ltrim():".strlen($str1)."
";
$str2=rtrim($str);
echo "The length after executing rtrim():".strlen($str2)."
";
$str3=trim($str);
echo "The length after executing trim():".strlen($str3)."
";
echo "The string after removing the leading and trailing spaces: [".$str3."]";
?>
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/917039.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/917039.htmlTechArticleInstances of ltrim(), rtrim() and trim() in php to delete character spaces, ltrimrtrim This article tells the example of php Methods for removing character spaces in ltrim(), rtrim() and trim(). Share it with everyone for your reference...
Statement: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