将制表符和空格替换为单个空格,将回车符和换行符替换为单个换行符
2022-08-30 12:01:14
$string = "My text has so much whitespace
Plenty of spaces and tabs";
echo preg_replace("/\s\s+/", " ", $string);
我阅读了PHP的文档并遵循了教程,但是此代码生成:preg_replace()
My text has so much whitespace Plenty of spaces and tabs
我怎么能把它变成:
My text has so much whitespace
Plenty of spaces and tabs