我想要去除那些不是兩個字母之間所有空格:條在一個PHP字符串中的所有不必要的空格
$string = " bah bah bah bah ";
$string = str_replace("/w /w", "+", $string);
// what goes here? to get this:
$string = "bah+bah+bah+bah";
的想法是,我想擺脫所有不必要的空格(不僅在開始和結束)。這不是一個鏈接,但對於一個搜索框,上提交將被分解,因此+甚至是=什麼的基本上
和$ string = trim($ string)將所有步驟縮合爲一個。好吧,我會接受它 – faq
是的,你也可以直接把它放在'preg_replace()' – casraf
爲什麼這個字符類? –