I tri开发者_运维百科ed
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 />
Use preg_replace
$str = preg_replace('/(\v|\s)+/', ' ', $str);
See http://codepad.org/2Dz1NmzD
this was better solution for me as suggested by LotusH in comments
$str = str_replace(array("\r\n", "\r", "\n", "\t"," "), '', $str);
精彩评论