screaming SiLENCE
screaming SiLENCE

Reputation: 214

PHP: Replace more then one Tab (\t) with one Tab

I have an array with sentences. Sometimes words are divided by tabs, sometimes one, sometimes more then one.

What I want is simple, I guess. I want to change the amount of tabs between words to 1 for all words divided by more then one tab.

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.

Thanks in advance!

Upvotes: 1

Views: 589

Answers (1)

Toto
Toto

Reputation: 91430

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

Upvotes: 5

Related Questions