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, ∼3648🔥, 0💬
Popular Posts:
How to how to use matched string and groups in replacements with re.sub()? When calling the re.sub()...
How to build a test service operation to dump everything from the "context.Request" object in the re...
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...
How to add an API to an API product for internal testing on the Publisher Portal of an Azure API Man...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...