How to Remove White Space from String in PHP?
Hey Folks,
If you need to see an example of how to remove space from string in php. you will learn how to remove all whitespace from a string in php. you can understand a concept of remove whitespace from string php. This article goes in detailed on remove space from string in php. Here, Create a basic example of delete space from string in php.
Sometimes we require to remove white space from given string. So at that time you can delete spaces from string using str_replace() of core php. str_replace() will help to replace whitespace that way we can remove. you can do it from bellow example.
Example:
index.php
<?php
/* Declare string variable */
$myString = "Welcome to ItSolutionStuff.com!";
/* remove white space from string in PHP */
$newString = str_replace(' ', '', $myString);
/* Echo resulted string */
echo $newString;
?>
Output:
WelcometoItSolutionStuff.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 First and Last Character from String in PHP?
- How to Get Last Character from String in PHP?
- How to Get First Character from String in PHP?
- How to Remove Last Character from String in PHP?
- How to Remove First Character from String in PHP?
- PHP Remove First and Last Character from String Example
- PHP Remove Whitespace from Beginning and End of String Example
- How to Check Query Execution Time in PHP?
- PHP CURL Post Request with Parameters Example
- PHP JQuery Chosen Ajax Autocomplete Example
- How to Get Folder Path from File Path in PHP?
- How to access PHP variables in JQuery?