3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL ^ E_NOTICE); $input = '<?xml version="1.0" ?><data><action>insert_message</action><reactid>00000000000000000000000000000000</reactid><topicid>126628</topicid><content><![CDATA[Test <a href="Wa">Meukee</a> Hoedel!]]></content><fields><mobile>iphone</mobile></fields></data>'; $xml_parser = xml_parser_create(''); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0); xml_parse_into_struct($xml_parser, $input, $vals); $inData = false; foreach($vals as $element) { if(strtolower($element['tag']) == 'data') { $inData = !$inData; } elseif($inData) { $data[ $element['tag'] ] = $element['value']; } } var_dump($data);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key "value" in /in/02869 on line 21 Warning: Undefined array key "value" in /in/02869 on line 21 array(6) { ["action"]=> string(14) "insert_message" ["reactid"]=> string(32) "00000000000000000000000000000000" ["topicid"]=> string(6) "126628" ["content"]=> string(36) "Test <a href="Wa">Meukee</a> Hoedel!" ["fields"]=> NULL ["mobile"]=> string(6) "iphone" }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 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.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
array(6) { ["action"]=> string(14) "insert_message" ["reactid"]=> string(32) "00000000000000000000000000000000" ["topicid"]=> string(6) "126628" ["content"]=> string(36) "Test <a href="Wa">Meukee</a> Hoedel!" ["fields"]=> NULL ["mobile"]=> string(6) "iphone" }

preferences:
311 ms | 405 KiB | 460 Q