1

我有一个带有句子的数组。有时单词被制表符分隔,有时一个,有时不止一个。

我想我想要的很简单。我想将单词之间的制表符数量更改为 1,以将所有单词除以一个以上的制表符。

Example, I want to change this:
\t\t This \t\t\t\t\t is \t\t a\t test.
into this:
\t This \t is \t a \t test.

提前致谢!

4

1 回答 1

5
$string = preg_replace("/\t+/", "\t", $string);
于 2012-04-20T14:04:11.283 回答