开发者

Strip new lines in PHP

开发者 https://www.devze.com 2023-03-21 14:38 出处:网络
I\'ve been working with phrases the past couple of d开发者_运维问答ays and the only problem I seem to be facing is stripping new lines in the html before printing it.

I've been working with phrases the past couple of d开发者_运维问答ays and the only problem I seem to be facing is stripping new lines in the html before printing it.

Anybody have any idea how to remove every new lines from HTML using PHP?


str_replace(array("\r", "\n"), '', $string)


the pt2ph8 answer didn't work for me until I have changed it a little bit as follows:

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

You can see the different results in this demo:

http://phpfiddle.org/lite/code/g5s8-nt3i

0

精彩评论

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

关注公众号