3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); function xml_encode($mixed, $DOMDocument=null) { if (is_null($DOMDocument)) { $DOMDocument =new DOMDocument; $DOMDocument->formatOutput = true; xml_encode($mixed, $DOMDocument); echo $DOMDocument->saveXML(); } else { if (is_array($mixed)) { $node = $DOMDocument->createElement('urlset', 'hello'); $DOMDocument->appendChild($node); } } } $data = array(); for ($x = 0; $x <= 10; $x++) { $data['urlset'][] = array( 'loc' => 'http://www.example.com/user', 'lastmod' => 'YYYY-MM-DD', 'changefreq' => 'monthly', 'priority' => 0.5 ); } header('Content-Type: application/xml'); echo xml_encode($data);

preferences:
33.25 ms | 402 KiB | 5 Q