PHP Remove Whitespace from Beginning and End of String Example
Hi Dev,
Now, let's see an example of php remove whitespace from beginning and end of string. I would like to share with you php remove space from beginning and end of string. let’s discuss about how to remove space from start and end of string in php. We will look at an example of remove first and last space from string in php.
We will use trim() php function to remove space from start to end of string in php. you can also use this example with laravel. so, let's see the simple example code with output.
index.php
<?php
$myString = " Hello ItSolutionStuff.com ";
$newString = trim($myString);
var_dump($newString);
?>
Output:
string(25) "Hello ItSolutionStuff.com"
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Get Previous Month from Date in PHP?
- How to Get HTML Tag Value in PHP?
- MySQL Query to Get Current Year Data Example
- How to Remove White Space from String in PHP?
- How to Quick Run PHP Project on Localhost?
- How to Check If String is URL or Not in PHP?
- How to Convert Array Key to Lowercase in PHP?
- How to Upload Image using jQuery Ajax in PHP?
- How to Remove Empty Values from Array in PHP?
- How to Get Minimum Key Value of Array in PHP?
- How to access PHP variables in JQuery?
- How to Count Number of Files in a Directory in PHP?
- How to Find Day Name from Specific Date in PHP?
- How to Remove Null Values from Array in PHP?