3v4l.org

run code in 300+ PHP versions simultaneously
<?php class BookXML extends \DOMDocument { public function filterByYear(int $year) { $books = []; $document = $this; $xpath = new DOMXPath($document); $booksObjs = $document->documentElement; $query = 'string(year)'; foreach ($booksObjs->childNodes as $booksObj) { $yearxml = $xpath->evaluate($query, $booksObj); if ($yearxml == $year) { $books[] = $booksObj; } } return $books; } } $content = ' <xml> <row> <year>2015</year> <month>september</month> </row> </xml> '; $xml = new BookXML(); $xml->loadXML($content); $filteredXML = $xml->filterByYear(2015); print_r($filteredXML);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => DOMElement Object ( [schemaTypeInfo] => [tagName] => row [firstElementChild] => (object value omitted) [lastElementChild] => (object value omitted) [childElementCount] => 2 [previousElementSibling] => [nextElementSibling] => [nodeName] => row [nodeValue] => 2015 september [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => (object value omitted) [nextSibling] => (object value omitted) [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => row [baseURI] => / [textContent] => 2015 september ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
29.67 ms | 409 KiB | 5 Q