开发者

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

开发者 https://www.devze.com 2023-04-05 14:53 出处:网络
I tri开发者_运维百科ed str_replace(array(\"\\r\\n\", \"\\r\", \"\\n\", \"\\t\"), \' \', $text);

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号