删除多余的空格,但不要删除两个单词之间的空格
我想删除字符串中存在的多余空格。我已经尝试过,和其他人,但不是他们工作,甚至尝试了以下的东西。trim
ltrim
rtrim
//This removes all the spaces even the space between the words
// which i want to be kept
$new_string = preg_replace('/\s/u', '', $old_string);
有什么解决方案吗?
已更新:-
输入字符串:-
"
Hello Welcome
to India "
输出字符串:-
"Hello Welcome to India"