3v4l.org

run code in 300+ PHP versions simultaneously
<?php $multiple = [ 'Mobiles' => [ 'MobileNo' => ['123', '456'] ] ]; $single = [ 'Mobiles' => [ 'MobileNo' => '123' ] ]; 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['Mobiles'] as $pNumber) { foreach($pNumber as $mobile ){ $i++; $array[$i]['SubmitResult'] = [ 'MobileNo' => $mobile, '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.70.0070.00716.88
8.3.60.0150.00618.55
8.3.50.0210.00416.43
8.3.40.0150.00318.91
8.3.30.0040.01119.09
8.3.20.0080.00019.45
8.3.10.0150.00023.70
8.3.00.0070.00723.79
8.2.190.0070.01116.75
8.2.180.0140.00718.79
8.2.170.0040.01122.96
8.2.160.0100.00519.27
8.2.150.0100.00024.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0080.00021.31
8.2.110.0060.00320.64
8.2.100.0070.00718.03
8.2.90.0030.00518.00
8.2.80.0050.00319.06
8.2.70.0030.00717.88
8.2.60.0040.00418.29
8.2.50.0040.00418.07
8.2.40.0040.00418.36
8.2.30.0000.00818.37
8.2.20.0070.00018.39
8.2.10.0000.00719.74
8.2.00.0040.00419.80
8.1.280.0040.01225.92
8.1.270.0080.00024.04
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00319.14
8.1.230.0040.00718.02
8.1.220.0040.00417.91
8.1.210.0000.00818.77
8.1.200.0030.00617.60
8.1.190.0040.00417.61
8.1.180.0000.00818.10
8.1.170.0040.00418.78
8.1.160.0000.00719.21
8.1.150.0000.00719.16
8.1.140.0070.00017.88
8.1.130.0040.00417.57
8.1.120.0070.00317.79
8.1.110.0000.00717.65
8.1.100.0000.00717.62
8.1.90.0050.00217.66
8.1.80.0000.00717.70
8.1.70.0000.01017.60
8.1.60.0030.00617.87
8.1.50.0050.00317.69
8.1.40.0000.00817.74
8.1.30.0050.00317.84
8.1.20.0000.00817.75
8.1.10.0040.00417.69
8.1.00.0000.00817.68
8.0.300.0040.00418.77
8.0.290.0030.00516.88
8.0.280.0000.00718.71
8.0.270.0070.00017.58
8.0.260.0030.00317.02
8.0.250.0030.00617.22
8.0.240.0030.00517.24
8.0.230.0000.00817.14
8.0.220.0070.00017.21
8.0.210.0000.00817.21
8.0.200.0060.00317.20
8.0.190.0000.00817.10
8.0.180.0080.00017.15
8.0.170.0060.00317.06
8.0.160.0040.00417.05
8.0.150.0040.00416.98
8.0.140.0040.00417.08
8.0.130.0030.00313.51
8.0.120.0040.00417.04
8.0.110.0000.00717.11
8.0.100.0040.00417.18
8.0.90.0030.00517.17
8.0.80.0050.01117.19
8.0.70.0040.00416.96
8.0.60.0000.00817.04
8.0.50.0000.00817.25
8.0.30.0100.00717.32
8.0.20.0110.00817.44
8.0.10.0000.00717.36
8.0.00.0100.00716.93
7.4.330.0020.00215.55
7.4.320.0080.00016.87
7.4.300.0070.00016.79
7.4.290.0040.00416.75
7.4.280.0020.00516.77
7.4.270.0070.00016.80
7.4.260.0090.00016.70
7.4.250.0030.00516.68
7.4.240.0050.00216.88
7.4.230.0070.00016.96
7.4.220.0030.00516.78
7.4.210.0080.00716.87
7.4.200.0030.00316.63
7.4.160.0060.01116.74
7.4.140.0100.00917.86
7.4.130.0090.00916.77
7.4.120.0110.01016.85
7.4.110.0030.01316.63
7.4.100.0100.00616.62
7.4.90.0120.01316.90
7.4.80.0110.00719.39
7.4.70.0110.01116.95
7.4.60.0060.01016.70
7.4.50.0070.01016.80
7.4.40.0030.01916.78
7.4.00.0040.01314.96
7.3.330.0000.00613.63
7.3.320.0060.00013.44
7.3.310.0040.00416.50
7.3.300.0000.00716.59
7.3.290.0070.00016.70
7.3.280.0060.01116.63
7.3.260.0100.00716.80
7.3.240.0080.01216.69
7.3.230.0070.01016.71
7.3.210.0090.00916.73
7.3.200.0130.00316.64
7.3.190.0070.01116.65
7.3.180.0070.01016.55
7.3.170.0100.00916.81
7.3.160.0100.01316.64
7.3.120.0070.01115.29
7.3.110.0070.01014.73
7.3.100.0100.00315.13
7.3.90.0100.00915.16
7.3.80.0070.00415.07
7.3.70.0040.01114.92
7.3.60.0030.01015.08
7.3.50.0030.00714.89
7.3.40.0140.00015.04
7.3.30.0090.00015.12
7.3.20.0030.01316.70
7.3.10.0030.01216.75
7.3.00.0030.01316.69
7.2.330.0090.01516.86
7.2.320.0070.01016.95
7.2.310.0180.00316.99
7.2.300.0130.01316.89
7.2.290.0160.01016.82
7.2.250.0040.01515.09
7.2.240.0100.00715.07
7.2.230.0070.01415.32
7.2.220.0000.01014.93
7.2.210.0160.00015.54
7.2.200.0040.00715.42
7.2.190.0000.00915.20
7.2.180.0040.01115.11
7.2.170.0030.00915.18
7.2.70.0220.01314.79
7.2.60.0140.01414.94
7.2.50.0600.00315.28
7.2.40.0190.01115.23
7.2.30.0230.00914.99
7.2.20.0170.01015.10
7.2.10.0220.01015.31
7.2.00.0170.01014.98
7.1.330.0060.00615.76
7.1.320.0060.00315.98
7.1.310.0070.00316.16
7.1.300.0060.00615.76
7.1.290.0070.00715.87
7.1.280.0000.01015.71
7.1.270.0070.00716.21
7.1.260.0070.00715.63
7.1.200.0060.00315.90
7.1.170.0150.01314.09
7.1.160.0230.00914.01
7.1.150.0190.01014.09
7.1.140.0220.00314.06
7.1.130.0180.01414.00
7.1.120.0170.01313.95
7.1.110.0170.01214.14
7.1.100.0180.01313.89
7.1.90.0210.00914.13
7.1.80.0670.01314.05
7.1.70.0210.01113.79
7.1.60.0420.01231.72
7.1.50.0430.01332.18
7.1.40.0480.01032.02
7.1.30.0300.01831.94
7.1.20.0380.01531.86
7.1.10.0280.00014.12
7.1.00.0180.00913.97

preferences:
45.99 ms | 401 KiB | 5 Q