3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<< EOT <?xml version='1.0' encoding='UTF-8'?> <eveapi version="2"> <currentTime>2013-10-01 18:00:01</currentTime> <result> <rowset name="members" key="characterID" columns="characterID, name"> <row characterID="2234" name="Bob"> <format type="test">Bob format</format> </row> <row characterID="555" name="John">test1 <format type="test">John format</format> </row> </rowset> </result> <cachedUntil>2013-10-01 18:57:01</cachedUntil> </eveapi> EOT; $simpleXML = simplexml_load_string($xml); // Load XML string data into the simplexml object parser foreach ($simpleXML->result->rowset as $rowset) { foreach ($rowset->row as $row) { $titles = []; echo "cp "; print_r($row); echo " cp "; $name = $row['name']->__toString(); foreach($row as $attrib){ if($attrib['name']->__toString() === 'titles'){ foreach($attrib as $title){ $titles[] = $title['titleName']->__toString(); } } } echo $name . ' : ' . implode(' - ', $titles) . "<br/>\n"; } }
Output for 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
cp SimpleXMLElement Object ( [@attributes] => Array ( [characterID] => 2234 [name] => Bob ) [format] => Bob format ) cp Fatal error: Uncaught Error: Call to a member function __toString() on null in /in/JKrKh:30 Stack trace: #0 {main} thrown in /in/JKrKh on line 30
Process exited with code 255.
Output for 7.3.17, 7.4.5
cp SimpleXMLElement Object ( [@attributes] => Array ( [characterID] => 2234 [name] => Bob ) [format] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => test ) [0] => Bob format ) ) cp Fatal error: Uncaught Error: Call to a member function __toString() on null in /in/JKrKh:30 Stack trace: #0 {main} thrown in /in/JKrKh on line 30
Process exited with code 255.
Output for 5.6.7 - 5.6.28
cp SimpleXMLElement Object ( [@attributes] => Array ( [characterID] => 2234 [name] => Bob ) [format] => Bob format ) cp Fatal error: Call to a member function __toString() on null in /in/JKrKh on line 30
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35
cp SimpleXMLElement Object ( [@attributes] => Array ( [characterID] => 2234 [name] => Bob ) [format] => Bob format ) cp Fatal error: Call to a member function __toString() on a non-object in /in/JKrKh on line 30
Process exited with code 255.
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/JKrKh on line 24
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected '[' in /in/JKrKh on line 25
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/JKrKh on line 24
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/JKrKh on line 24
Process exited with code 255.

preferences:
235.6 ms | 401 KiB | 357 Q