【发布时间】:2012-06-04 07:54:44
【问题描述】:
我有一个包含多个换行符的字符串。
字符串:
This is a dummy text. I need
to format
this.
期望的输出:
This is a dummy text. I need to format this.
我正在使用这个:
$replacer = array("\r\n", "\n", "\r", "\t", " ");
$string = str_replace($replacer, "", $string);
但它没有按预期/要求工作。有些单词之间没有空格。
实际上我需要将字符串中的所有单词用单个空格分隔。
【问题讨论】:
标签: php string whitespace normalize