2012-04-20 15 views
1

私は文を持つ配列を持っています。時には単語はタブ、時には1つ、時には1つに分割されることもあります。PHP:1つ以上のTab( t)を1つのタブに置き換えます。

私が欲しいのは簡単だと思います。私はすべての単語が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. 

ありがとうございます!

答えて

5
$string = preg_replace("/\t+/", "\t", $string); 
+0

@drrcknlsn:typo :-)を訂正していただきありがとうございます。 – Toto

+0

ありがとうございます! –

+0

@screamingSiLENCE:どうぞよろしくお願いいたします。 – Toto

関連する問題