JEdot JEdot - 5 months ago 31
PHP Question

How I can format this line into formatted code using regex

How I can convert this line :


into something formatted like :


using regex.

Also I dont understand why
(an instance of DOMDocument) return the result as one line only.


Actually using regex would be the longer option. Rather use

$doc->preserveWhiteSpace = false;
$doc->formatOutput = true;
$xml_string = $doc->saveXML();
echo $xml_string;

This should get you the formatted code.