Reputation: 3401
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
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
Reputation: 7722
Use preg_replace
$str = preg_replace('/(\v|\s)+/', ' ', $str);
See http://codepad.org/2Dz1NmzD
Upvotes: 14