If you want to replace multiple space with single space from a string you can use preg_replace function for this. Refer the below example

preg_replace(“!\s+!”,” “,$yourstring);

For example
$yourstring = “This contain space”;
$modifiedString = preg_replace(“!\s+!”,” “,$yourstring);
echo $modifiedString;
// This contain space // output

By admin

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.