开发者

removing blank lines from XHTML

开发者 https://www.devze.com 2023-01-08 02:40 出处:网络
I have XHTML that has empty (blank) lines: some_tag empty line empty line empty line some_tag I wonder how to get rid of them using PHP str_replace. The result should be开发者_如何学C some_tag

I have XHTML that has empty (blank) lines:

some_tag

empty line

empty line

empty line

some_tag

I wonder how to get rid of them using PHP str_replace. The result should be开发者_如何学C some_tag some_tag. What are these blank lines anyways?


$output = str_replace(array("\n", "\r"), '', $input);

OK, after that everything will be in one line. Hope that's ok. Otherwise you'd have to use regular expressions to get rid only of line breaks which are not within tags.

0

精彩评论

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

关注公众号