3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>'. '<request><body test2="321" test3="987">'. '<rows><my-row test4="564">'. '<types>'. '<custom>this is the example of the text</custom>'. '<Generic arch="simple">this is the example of the text</Generic>'. '<bold/><italic/><underlined/>'. '</types>'. '</my-row><my-row test5="565"/><test hidden="false" ready="true"/></rows>'. '</body></request>'; $obj = new SimpleXmlIterator($s); foreach ($obj as $key => $value) { var_dump($key, $value, '<hr/>'); }
Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.16, 7.3.18 - 7.3.33, 7.4.0 - 7.4.4, 7.4.6 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
string(4) "body" object(SimpleXMLIterator)#3 (2) { ["@attributes"]=> array(2) { ["test2"]=> string(3) "321" ["test3"]=> string(3) "987" } ["rows"]=> object(SimpleXMLIterator)#4 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#5 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#8 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#9 (0) { } ["italic"]=> object(SimpleXMLIterator)#10 (0) { } ["underlined"]=> object(SimpleXMLIterator)#11 (0) { } } } [1]=> object(SimpleXMLIterator)#6 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } } ["test"]=> object(SimpleXMLIterator)#7 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } } } string(5) "<hr/>"
Output for 7.3.17, 7.4.5
string(4) "body" object(SimpleXMLIterator)#3 (2) { ["@attributes"]=> array(2) { ["test2"]=> string(3) "321" ["test3"]=> string(3) "987" } ["rows"]=> object(SimpleXMLIterator)#4 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#5 (2) { ["@attributes"]=> array(1) { ["test4"]=> string(3) "564" } ["types"]=> object(SimpleXMLIterator)#8 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> object(SimpleXMLIterator)#9 (2) { ["@attributes"]=> array(1) { ["arch"]=> string(6) "simple" } [0]=> string(31) "this is the example of the text" } ["bold"]=> object(SimpleXMLIterator)#10 (0) { } ["italic"]=> object(SimpleXMLIterator)#11 (0) { } ["underlined"]=> object(SimpleXMLIterator)#12 (0) { } } } [1]=> object(SimpleXMLIterator)#6 (1) { ["@attributes"]=> array(1) { ["test5"]=> string(3) "565" } } } ["test"]=> object(SimpleXMLIterator)#7 (1) { ["@attributes"]=> array(2) { ["hidden"]=> string(5) "false" ["ready"]=> string(4) "true" } } } } string(5) "<hr/>"
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
string(4) "body" object(SimpleXMLIterator)#3 (1) { ["rows"]=> object(SimpleXMLIterator)#4 (2) { ["my-row"]=> array(2) { [0]=> object(SimpleXMLIterator)#5 (1) { ["types"]=> object(SimpleXMLIterator)#8 (5) { ["custom"]=> string(31) "this is the example of the text" ["Generic"]=> string(31) "this is the example of the text" ["bold"]=> object(SimpleXMLIterator)#9 (0) { } ["italic"]=> object(SimpleXMLIterator)#10 (0) { } ["underlined"]=> object(SimpleXMLIterator)#11 (0) { } } } [1]=> object(SimpleXMLIterator)#6 (0) { } } ["test"]=> object(SimpleXMLIterator)#7 (0) { } } } string(5) "<hr/>"
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmliterator in /in/KKTVl on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmliterator in /in/KKTVl on line 12

preferences:
260.68 ms | 401 KiB | 384 Q