How to remove double spaces from a string in PHP

1 Answer

0 votes
$s = "php  java  python c#  c++";
 
$s = preg_replace('/\s+/', ' ', $s);
 
echo $s;
 
   
/*
run:
    
php java python c# c++
    
*/

 



answered Oct 11, 2018 by avibootz

Related questions

1 answer 213 views
2 answers 273 views
1 answer 180 views
2 answers 223 views
1 answer 157 views
...