3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json_1 = '[{"MobileNo":"123"},{"MobileNo":"456"}]'; $json_2 = '[{"MobileNo":"07123456701"}]'; $multiple = json_decode($json_1, true); $single = json_decode($json_2, true); class convert{ public function arrayToXml($array, $xml) { foreach ($array as $key => $value) { if (is_array($value)) { self::arrayToXml($value, $xml->addChild($key)); } else { if (is_numeric($key)) { $xml->addChild(preg_replace('/s$/', '', $xml->getName()), $value); } else { $xml->addChild($key, $value); } } } } } $xml = new \SimpleXMLElement('<Msg />'); $array = [ 'JobId' => 77]; $i = 0; foreach ($multiple as $mobile) { $i++; $array[$i]['SubmitResult'] = [ 'MobileNo' => $mobile['MobileNo'], 'StatusId' => 0000, 'StatusText' =>'Success: Message submitted successfully', ]; } //print_r($array); $convert = new convert(); $convert->arrayToXml($array, $xml); var_dump($xml->asXML());

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.3.60.0090.00618.52
8.3.50.0120.00617.02
8.3.40.0060.01619.09
8.3.30.0060.00918.70
8.3.20.0040.00419.41
8.3.10.0070.00723.83
8.3.00.0040.00423.91
8.2.180.0120.00318.67
8.2.170.0040.01122.96
8.2.160.0100.00319.32
8.2.150.0070.00424.18
8.2.140.0090.00024.66
8.2.130.0070.00020.72
8.2.120.0050.00326.35
8.2.110.0000.00922.50
8.2.100.0070.01118.16
8.2.90.0000.00818.00
8.2.80.0040.00418.98
8.2.70.0060.00617.88
8.2.60.0080.00017.88
8.2.50.0000.00817.88
8.2.40.0080.00019.73
8.2.30.0060.00319.68
8.2.20.0040.00418.37
8.2.10.0040.00419.65
8.2.00.0000.00719.67
8.1.280.0090.00925.92
8.1.270.0000.00822.33
8.1.260.0050.00326.35
8.1.250.0060.00328.09
8.1.240.0030.00624.04
8.1.230.0040.00719.29
8.1.220.0060.00318.85
8.1.210.0000.00818.77
8.1.200.0040.00417.46
8.1.190.0060.00317.47
8.1.180.0050.00318.10
8.1.170.0070.00019.27
8.1.160.0040.00419.00
8.1.150.0000.00819.22
8.1.140.0070.00017.96
8.1.130.0040.00419.27
8.1.120.0040.00417.77
8.1.110.0040.00417.68
8.1.100.0070.00017.68
8.1.90.0030.00617.66
8.1.80.0070.00017.72
8.1.70.0070.00017.70
8.1.60.0030.00517.86
8.1.50.0040.00417.77
8.1.40.0040.00417.72
8.1.30.0040.00417.90
8.1.20.0000.00817.88
8.1.10.0000.00717.66
8.1.00.0030.00617.68
8.0.300.0000.00718.77
8.0.290.0040.00417.00
8.0.280.0040.00418.61
8.0.270.0000.00717.50
8.0.260.0040.00717.51
8.0.250.0030.00617.20
8.0.240.0000.00817.07
8.0.230.0050.00517.27
8.0.220.0070.00017.14
8.0.210.0070.00017.13
8.0.200.0090.00017.19
8.0.190.0040.00417.08
8.0.180.0040.00417.02
8.0.170.0060.00317.19
8.0.160.0000.00717.10
8.0.150.0000.00717.11
8.0.140.0030.00317.18
8.0.130.0000.00613.50
8.0.120.0040.00417.15
8.0.110.0000.00717.02
8.0.100.0070.00017.22
8.0.90.0020.00517.21
8.0.80.0100.00917.12
8.0.70.0040.00417.22
8.0.60.0040.00417.17
8.0.50.0080.00017.04
8.0.30.0080.01217.40
8.0.20.0120.00817.40
8.0.10.0000.00717.14
8.0.00.0090.00916.95
7.4.330.0000.00515.55
7.4.320.0030.00316.68
7.4.300.0030.00316.82
7.4.290.0030.00516.86
7.4.280.0050.00316.74
7.4.270.0050.00216.82
7.4.260.0060.00316.74
7.4.250.0040.00416.77
7.4.240.0090.00016.91
7.4.230.0000.00716.86
7.4.220.0000.00716.60
7.4.210.0110.00516.84
7.4.200.0000.00816.89
7.4.160.0100.00616.86
7.4.140.0130.01017.86
7.4.130.0130.00616.80
7.4.120.0080.01016.80
7.4.110.0110.00816.88
7.4.100.0070.01116.88
7.4.90.0030.01516.79
7.4.80.0040.01319.39
7.4.70.0080.00816.75
7.4.60.0150.00316.66
7.4.50.0030.01216.64
7.4.40.0180.00016.90
7.4.00.0080.00714.99
7.3.330.0020.00213.48
7.3.320.0050.00013.48
7.3.310.0040.00316.47
7.3.300.0050.00316.50
7.3.290.0030.00316.64
7.3.280.0050.01216.59
7.3.260.0110.00916.72
7.3.240.0110.00916.68
7.3.230.0030.01316.53
7.3.210.0120.00616.63
7.3.200.0030.01316.57
7.3.190.0060.01116.90
7.3.180.0100.00716.80
7.3.170.0080.00816.77
7.3.160.0040.01216.57
7.3.120.0040.01415.16
7.3.110.0000.01414.87
7.3.100.0040.01115.18
7.3.90.0030.00615.28
7.3.80.0100.00015.11
7.3.70.0000.01114.97
7.3.60.0030.01614.96
7.3.50.0150.00614.96
7.3.40.0040.01114.85
7.3.30.0040.01115.17
7.3.20.0100.00316.79
7.3.10.0000.01416.63
7.3.00.0060.00916.69
7.2.330.0130.00616.91
7.2.320.0120.00917.02
7.2.310.0030.02016.89
7.2.300.0000.01716.94
7.2.290.0160.00616.93
7.2.250.0070.01015.27
7.2.240.0070.01315.34
7.2.230.0090.00615.16
7.2.220.0110.00314.89
7.2.210.0000.01714.91
7.2.200.0030.01015.16
7.2.190.0140.00315.12
7.2.180.0030.01515.08
7.2.170.0060.01015.13
7.2.70.0220.01115.30
7.2.60.0190.01415.27
7.2.50.0270.00615.11
7.2.40.0260.00715.30
7.2.30.0200.01615.26
7.2.20.0160.01315.08
7.2.10.0170.01715.08
7.2.00.0130.01315.20
7.1.330.0060.00915.84
7.1.320.0100.00315.97
7.1.310.0040.01115.95
7.1.300.0070.01115.86
7.1.290.0000.01815.88
7.1.280.0070.00715.82
7.1.270.0030.01015.99
7.1.260.0070.00715.88
7.1.200.0060.00315.87
7.1.170.0240.00913.82
7.1.160.0200.01013.96
7.1.150.0150.00513.80
7.1.140.0210.01114.21
7.1.130.0210.00613.98
7.1.120.0100.01614.09
7.1.110.0220.00614.17
7.1.100.0180.01414.11
7.1.90.0100.01913.94
7.1.80.0320.01514.21
7.1.70.0230.00314.15
7.1.60.0390.01032.05
7.1.50.0450.00932.07
7.1.40.0460.00631.92
7.1.30.0460.01032.01
7.1.20.0340.01231.74
7.1.10.0250.00413.98
7.1.00.0230.00714.22

preferences:
39.64 ms | 400 KiB | 5 Q