3v4l.org

run code in 500+ PHP versions simultaneously
<?php $xml = new SimpleXMLElement('<foo bar="baz"></foo>'); function iterator(SimpleXMLElement $xml): iterable { foreach ($xml->children() as $img) { yield $img["src"] ?? ""; } } iterator_to_array(iterator($xml->bar));
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Warning: foreach() argument must be of type array|object, null given in /in/rqvMc on line 6
Output for 7.4.0 - 7.4.33
Warning: iterator(): Node no longer exists in /in/rqvMc on line 6

preferences:
98.53 ms | 1247 KiB | 4 Q