所以,如果我有一个像"hello what is my name" 如何占用所有空间并仅用一个空间替换每个空间? 最佳答案 这应该做到这一点:$replaced = preg_replace('/\s\s+/', ' ', $text); 输出:hello what is my name