dotslashlu
dotslashlu

Reputation: 3401

I tried to remove \r \n \t but there are still tabs

I tried

str_replace(array("\r\n", "\r", "\n", "\t"), ' ', $text);

It could strip new lines but there are still some tabs as you can see below. what's the preblem?

Metal Machine Music, Part I<br /> <br />     <br /> <br />     <br />     <br />     <br />     <br /> <br /> Metal Machine Music, Part II<br /> <br />     <br /> <br />     <br />     <br />     <br />     <br /> <br /> Metal Machine Music, Part III<br /> <br />     <br /> <br />     <br />     <br />     <br />     <br /> <br />   

Upvotes: 2

Views: 14319

Answers (2)

up2europe
up2europe

Reputation: 41

this was better solution for me as suggested by LotusH in comments

$str = str_replace(array("\r\n", "\r", "\n", "\t"," "), '', $str);

Upvotes: 1

rabudde
rabudde

Reputation: 7722

Use preg_replace

$str = preg_replace('/(\v|\s)+/', ' ', $str);

See http://codepad.org/2Dz1NmzD

Upvotes: 14

Related Questions