I am using XPath to get some paragraphs from my DomDocument. This works fine and returns me the desired data.
The problem is that when doing:
foreach ($paragraph->childNodes as $child) {
$node .= $paragraph->ownerDocument->saveHTML($child);
}
If there is an initial line break, this will be keept, and I would like to get rid of all linebreaks.
I tryed:
$node = trim($node); // Does not work
Then:
$breaks = array("\r\n", "\n", "\r");
$node = str_replace($breaks, " ", $node); // Doesn't work
I also tryed:
$paragraph->ownerDocument->formatOutput = false;
$paragraph->ownerDocument->preserveWhiteSpace = false;
Did not work.
Any Idea on how to get rid of those line breaks ?
Thank you in advance.
EDIT
Here is an example of the $node input:
<b>Keywords: </b>marine fungus; sediment; anthranilic acid; <i>Penicillium paneum</i>; cytotoxicity
Apparently, the problematic character is
what is this special character ?