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, ∼3250🔥, 0💬
Popular Posts:
Where to get a real Atom XML example? You can follow this tutorial to get a real Atom XML example: 1...
How to view API details on the Publisher Dashboard of an Azure API Management Service? You can follo...
How to build a PHP script to dump Azure AD 2.0 Authentication Response? If you are use the Azure-AD-...
What validation keywords I can use in JSON Schema to specifically validate JSON Array values? The cu...
How to make application release build with Visual Studio 2017? If you want to make a final release b...