Tools, FAQ, Tutorials:
Ways to Remove Leading and Trailing White Spaces in PHP
How Many ways to Remove Leading and Trailing White Spaces?
✍: FYIcenter.com
There are 4 PHP functions you can use remove white space characters from the beginning and/or the end of a string:
White space characters are defined as:
Here is a PHP script example of trimming strings:
<?php
$text = "\t \t Hello world!\t \t ";
$leftTrimmed = ltrim($text);
$rightTrimmed = rtrim($text);
$bothTrimmed = trim($text);
print("leftTrimmed = ($leftTrimmed)\n");
print("rightTrimmed = ($rightTrimmed)\n");
print("bothTrimmed = ($bothTrimmed)\n");
?>
This script will print:
leftTrimmed = (Hello world! ) rightTrimmed = ( Hello world!) bothTrimmed = (Hello world!)
⇒ Remove Trailing New Line Character in PHP
⇐ Counting the Number of Characters in PHP
2016-10-13, ∼3249🔥, 0💬
Popular Posts:
How to use .NET CLR Types in Azure API Policy? By default, Azure imports many basic .NET CLR (Common...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...
How to run PowerShell Commands in Dockerfile to change Windows Docker images? When building a new Wi...
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...
How to install "C++/CLI Support" component in Visual Studio? I need to build my Visual Studio C++/CL...