How to remove white space from string in PHP?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this example i will show you How to remove white space from string in PHP? Sometimes we need to remove the white space from the given string. So at that times we need to delete the spaces from string by using str_replace() of core php. we know str_replace() will help us to replace the white space on that way we can remove this. So we can do this from the bellow example.

Example:
$myString = "this is only for you";
$resultString = str_replace(' ', '', $myString);
print_r($resultString);

Read Also: Generate Captcha code and Validation by using BotDetect package in laravel

Thanks for read. I hope it help you. For more you can follow us on facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →