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, 2630🔥, 0💬
Popular Posts:
How to access Query String parameters from "context.Request.Url.Que ry"object in Azure API Policy? Q...
How to read RSS validation errors at w3.org? If your RSS feed has errors, the RSS validator at w3.or...
What Azure AD App Registration Manifest? Azure AD App Registration Manifest is JSON file that contai...
Where to find tutorials on Python programming language? I want to learn Python. Here is a large coll...
Can Multiple Paragraphs Be Included in a List Item? Yes. You can include multiple paragraphs in a si...