3v4l.org

run code in 300+ PHP versions simultaneously
<?php function process_xml(string $xml_string) : array { // Process XML $xml = simplexml_load_string($xml_string); // Return array $my_json['messages'] = []; // Iterate over nodes foreach($xml->children() as $message) { // Technically not needed $tmp = []; // Iterate over attributes foreach($message->attributes() as $name => $value) { $tmp[$name] = $value; } $my_json['messages'][] = $tmp; } return $my_json; } $xml_string_1 = <<<EOT <messages> <message message="asdf" franchise_id="0000" id="1661170418wng204" posted="Mon Aug 22 8:13:38 a.m. ET 2022"/> </messages> EOT; $xml_string_2 = <<<EOT <messages> <message franchise_id="0000" id="1661174329csw208" posted="Mon Aug 22 9:18:49 a.m. ET 2022" message="asdf"/> <message id="1661170418wng204" posted="Mon Aug 22 8:13:38 a.m. ET 2022" franchise_id="0000" message="asdf"/> </messages> EOT; echo json_encode(process_xml($xml_string_1)); echo PHP_EOL; echo json_encode(process_xml($xml_string_2));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.120.0110.00924.28
8.4.110.0130.00722.59
8.4.100.0140.00617.99
8.4.90.0110.01017.87
8.4.80.0060.00318.14
8.4.70.0070.00418.11
8.4.60.0130.00919.75
8.4.50.0130.00718.94
8.4.40.0080.00018.09
8.4.30.0100.01020.66
8.4.20.0100.01017.88
8.4.10.0080.00422.24
8.3.250.0050.00319.32
8.3.240.0110.00917.47
8.3.230.0130.00616.71
8.3.220.0040.00417.34
8.3.210.0140.00516.66
8.3.200.0090.01016.94
8.3.190.0120.00816.66
8.3.180.0050.00318.65
8.3.170.0150.00418.98
8.3.160.0070.01320.34
8.3.150.0080.00018.70
8.3.140.0040.01417.45
8.3.130.0050.00518.86
8.3.120.0060.00320.70
8.3.110.0060.00316.73
8.3.100.0000.00917.05
8.3.90.0140.00426.77
8.3.80.0050.00517.13
8.3.70.0100.01016.75
8.3.60.0070.00716.88
8.3.50.0070.00720.26
8.3.40.0000.01422.32
8.3.30.0040.01119.04
8.3.20.0000.00824.18
8.3.10.0050.00324.66
8.3.00.0040.00426.16
8.2.290.0100.00820.57
8.2.280.0110.00918.36
8.2.270.0120.00619.35
8.2.260.0060.01216.51
8.2.250.0090.00917.30
8.2.240.0000.00817.18
8.2.230.0080.00020.94
8.2.220.0060.00924.06
8.2.210.0050.00326.77
8.2.200.0030.00718.54
8.2.190.0110.01116.88
8.2.180.0040.01125.92
8.2.170.0090.00619.16
8.2.160.0110.00322.96
8.2.150.0080.00025.66
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0030.01026.16
8.2.110.0030.00620.64
8.2.100.0060.00320.60
8.1.330.0090.00722.51
8.1.320.0080.01116.54
8.1.310.0130.00618.69
8.1.300.0130.00317.11
8.1.290.0030.00630.84
8.1.280.0090.00625.92
8.1.270.0040.00424.66
8.1.260.0000.00726.35
8.1.250.0030.00528.09
8.1.240.0030.00618.69
8.1.230.0030.00918.70
8.1.90.0080.00217.67

preferences:
27.4 ms | 403 KiB | 5 Q