Page 1 of 1

New Lines - and headaches!

Posted: Sat Aug 10, 2002 12:03 am
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.

Posted: Sat Aug 10, 2002 2:05 am
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);