New Lines - and headaches!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
battman21
Forum Newbie
Posts: 3
Joined: Sun Aug 04, 2002 12:57 am

New Lines - and headaches!

Post by battman21 »

Slight problem. I need to strip out new lines between lines of text (in this case XML) - not a problem - however, if i do a replace on \n then it will destroy my formating of the XML, which of course i want to keep.

eg.

<device>
<header>
<Device_ID>00001</Device_ID>
</header>
<default>



<device>
<header>
<Device_ID>00001</Device_ID>
</header>
<default>

I need to get rid of the spaces in between the two device descriptions. Ideas?

Thanks in advance.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

array_filter

Code: Select all

function filter_empty($s)
&#123;
  return ($s!="\n" && $s!="\r\n");
&#125;

$xml = <string-array>
$xml = array_filter($xml);
Post Reply