3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); global $n; $n = 0; function convert($xml) { $simpleXmlObj = simplexml_load_string($xml); $array = toarray($simpleXmlObj); return $array; } function toarray($simpleXmlObj) { $simpleXmlObjNew = array(); foreach (array_keys((array) $simpleXmlObj) as $element) { $el = (array) $simpleXmlObj->$element; if (isset($el[0])) { if (is_object($el[0])) { $r = (array) $el[0]; if (isset($r[0])) { $el[0] = $r[0]; } } $trim = $el[0]; $simpleXmlObjNew[$element] = $trim; } else { $simpleXmlObjNew[$element] = toarray($simpleXmlObj->$element); } if (empty($simpleXmlObjNew[$element])) { $simpleXmlObjNew[$element] = ''; } } return $simpleXmlObjNew; } $xml = <<<xml <?xml version="1.0" encoding="utf-8"?> <RESPONSE> <e></e> <e1> </e1> <e2> s </e2> <e3>s</e3> <e4> </e4> </RESPONSE> xml; $simpleXmlObj = simplexml_load_string($xml); $response = toarray($simpleXmlObj); print_r($response);

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.00916.88
8.3.50.0110.01121.29
8.3.40.0090.00618.96
8.3.30.0110.00418.78
8.3.20.0040.00420.59
8.3.10.0140.00423.85
8.3.00.0040.00419.68
8.2.180.0120.00316.88
8.2.170.0110.00422.96
8.2.160.0180.00320.47
8.2.150.0070.01124.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0060.00317.75
8.2.110.0030.00721.19
8.2.100.0090.00317.97
8.2.90.0030.00619.46
8.2.80.0030.00517.97
8.2.70.0030.00617.75
8.2.60.0080.00018.05
8.2.50.0060.00318.17
8.2.40.0000.00720.70
8.2.30.0000.00718.22
8.2.20.0040.00418.05
8.2.10.0040.00418.26
8.2.00.0040.00418.43
8.1.280.0090.00925.92
8.1.270.0040.01420.51
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0000.00922.39
8.1.230.0090.00317.76
8.1.220.0030.00618.04
8.1.210.0000.00818.77
8.1.200.0030.00717.60
8.1.190.0090.00317.36
8.1.180.0040.00418.10
8.1.170.0040.00418.49
8.1.160.0000.00722.25
8.1.150.0020.00519.09
8.1.140.0040.00417.75
8.1.130.0040.00417.94
8.1.120.0000.00717.66
8.1.110.0040.00417.63
8.1.100.0000.00817.68
8.1.90.0000.00717.72
8.1.80.0030.00517.61
8.1.70.0080.00017.73
8.1.60.0000.00817.72
8.1.50.0040.00417.75
8.1.40.0080.00017.83
8.1.30.0040.00417.80
8.1.20.0050.00317.82
8.1.10.0060.00317.65
8.1.00.0080.00017.57
8.0.300.0050.00518.77
8.0.290.0040.00417.00
8.0.280.0070.00018.60
8.0.270.0000.00717.40
8.0.260.0000.00617.43
8.0.250.0070.00017.29
8.0.240.0070.00017.31
8.0.230.0040.00417.16
8.0.220.0070.00017.23
8.0.210.0080.00017.19
8.0.200.0030.00317.19
8.0.190.0030.00617.22
8.0.180.0040.00417.30
8.0.170.0000.00717.17
8.0.160.0040.00417.34
8.0.150.0040.00417.06
8.0.140.0070.00017.12
8.0.130.0050.00213.70
8.0.120.0040.00417.16
8.0.110.0030.00517.16
8.0.100.0070.00017.16
8.0.90.0000.00717.32
8.0.80.0070.01717.11
8.0.70.0030.00617.21
8.0.60.0030.00517.22
8.0.50.0040.00417.17
8.0.30.0120.00817.39
8.0.20.0140.00517.44
8.0.10.0000.00817.43
8.0.00.0140.00617.07
7.4.330.0000.00515.34
7.4.320.0000.00616.84
7.4.300.0030.00316.81
7.4.290.0040.00416.76
7.4.280.0060.00316.71
7.4.270.0070.00016.85
7.4.260.0000.00816.63
7.4.250.0050.00216.70
7.4.240.0040.00416.70
7.4.230.0030.00316.93
7.4.220.0120.00416.89
7.4.210.0110.00816.78
7.4.200.0030.00316.57
7.4.160.0130.00316.78
7.4.150.0060.01617.40
7.4.140.0130.00817.86
7.4.130.0120.00816.75
7.4.120.0090.00716.62
7.4.110.0140.00316.69
7.4.100.0060.01616.73
7.4.90.0030.01516.86
7.4.80.0070.01019.39
7.4.70.0090.00916.70
7.4.60.0120.00416.77
7.4.50.0000.00816.72
7.4.40.0030.01416.71
7.4.30.0120.00916.48
7.4.00.0060.01215.28
7.3.330.0000.00713.64
7.3.320.0030.00313.63
7.3.310.0000.00716.71
7.3.300.0040.00416.53
7.3.290.0030.00316.64
7.3.280.0090.00916.65
7.3.270.0030.01517.40
7.3.260.0060.01216.63
7.3.250.0110.00616.64
7.3.240.0130.01316.83
7.3.230.0090.00916.62
7.3.210.0120.00516.63
7.3.200.0030.01316.88
7.3.190.0070.01016.92
7.3.180.0100.00716.82
7.3.170.0030.01416.66
7.3.160.0100.00716.60
7.2.330.0060.01916.63
7.2.320.0120.00816.69
7.2.310.0000.01616.92
7.2.300.0060.01616.97
7.2.290.0160.00316.88
7.2.60.0080.00816.79
7.2.00.0030.00619.68
7.1.200.0080.00315.84
7.1.100.0030.01018.06
7.1.70.0050.00517.16
7.1.60.0110.01520.03
7.1.50.0100.01316.81
7.1.00.0030.09322.41
7.0.200.0210.00314.96
7.0.60.0130.05020.13
7.0.50.0100.05017.95
7.0.40.0130.08020.47
7.0.30.0300.06720.21
7.0.20.0330.07020.20
7.0.10.0070.09320.21
7.0.00.0070.08320.21
5.6.280.0030.06721.03
5.6.210.0170.07020.63
5.6.200.0070.09018.31
5.6.190.0030.09320.81
5.6.180.4100.04320.49
5.6.170.0330.07020.61
5.6.160.0170.05720.66
5.6.150.0130.04018.30
5.6.140.0030.08718.27
5.6.130.0130.07018.34
5.6.120.0030.09021.07
5.6.110.0000.05021.16
5.6.100.0000.04320.99
5.6.90.0100.08021.02
5.6.80.0130.05020.36
5.6.70.3130.03020.55
5.5.350.0270.07320.45
5.5.340.0170.07318.21
5.5.330.0030.04020.36
5.5.320.3370.04320.33
5.5.310.0300.07320.34
5.5.300.0070.05718.07
5.5.290.0070.04718.15
5.5.280.0070.08321.08
5.5.270.0130.07320.73
5.5.260.0070.05320.84
5.5.250.0070.06320.83
5.5.240.0270.07320.23
5.4.450.0330.06719.69
5.4.440.0330.06019.78
5.4.430.0070.07319.65
5.4.420.0200.06019.36
5.4.410.0230.04319.58
5.4.400.0300.04719.37
5.4.390.0270.05319.39
5.4.380.0230.06019.04
5.4.370.0100.05719.05
5.4.360.0300.05719.06
5.4.350.0170.05019.05
5.4.340.0070.06019.36
5.4.320.0230.04719.19
5.4.310.0130.05019.21
5.4.300.0130.05319.21
5.4.290.0200.05319.21
5.4.280.0270.05319.44
5.4.270.0400.05019.07
5.4.260.0530.06319.36
5.4.250.0270.05319.19
5.4.240.0200.06019.39
5.4.230.0230.06719.03
5.4.220.0370.06019.21
5.4.210.0100.05719.02
5.4.200.0200.04719.23
5.4.190.0070.07719.34
5.4.180.0170.04719.21
5.4.170.0200.05719.43
5.4.160.0330.05719.32
5.4.150.0370.06319.03
5.4.140.0200.05316.64
5.4.130.0100.06316.56
5.4.120.0400.04316.74
5.4.110.0170.05316.64
5.4.100.0170.04716.79
5.4.90.0200.04016.57
5.4.80.0700.04316.64
5.4.70.0600.05716.73
5.4.60.0230.04316.71
5.4.50.0300.03316.61
5.4.40.0170.05016.71
5.4.30.0100.06016.71
5.4.20.0070.05716.70
5.4.10.0100.06016.73
5.4.00.0130.04715.88
5.3.290.0200.05014.78
5.3.280.0270.04014.82
5.3.270.0170.05314.76
5.3.260.0130.06014.71
5.3.250.0100.07014.81
5.3.240.0170.05014.72
5.3.230.0100.05714.71
5.3.220.0270.05714.70
5.3.210.0270.06014.73
5.3.200.0100.05714.70
5.3.190.0130.06714.68
5.3.180.0130.05014.87
5.3.170.0130.05314.90
5.3.160.0130.05714.67
5.3.150.0370.05714.73
5.3.140.0170.04314.71
5.3.130.0170.05014.71
5.3.120.0330.05014.67
5.3.110.0100.05314.70
5.3.100.0100.05314.20
5.3.90.0030.07014.14
5.3.80.0570.04314.31
5.3.70.0270.05314.12
5.3.60.0430.04714.34
5.3.50.0300.04714.32
5.3.40.0000.06014.29
5.3.30.0100.05013.96
5.3.20.0130.05714.07
5.3.10.0100.05013.71
5.3.00.0130.05713.80
5.2.170.0070.04311.21
5.2.160.0400.03711.43
5.2.150.0430.04011.20
5.2.140.0070.06011.25
5.2.130.0200.05711.22
5.2.120.0100.04011.39
5.2.110.0130.03711.21
5.2.100.0130.03711.17
5.2.90.0200.03711.43
5.2.80.0100.04011.43
5.2.70.0000.05311.21
5.2.60.0300.04711.20
5.2.50.0270.03311.09
5.2.40.0030.05011.04
5.2.30.0130.04311.20
5.2.20.0000.04711.08
5.2.10.0130.03310.97
5.2.00.0130.03310.78
5.1.60.0100.03010.07
5.1.50.0130.03010.38
5.1.40.0000.04010.14
5.1.30.0170.04310.39
5.1.20.0400.03310.48
5.1.10.0330.03710.40
5.1.00.0100.04710.21
5.0.50.0030.0338.64
5.0.40.0030.0308.52
5.0.30.0070.0438.57
5.0.20.0200.0238.35
5.0.10.0170.0378.26
5.0.00.0030.0508.29
4.4.90.0070.0205.88
4.4.80.0070.0205.88
4.4.70.0030.0275.78
4.4.60.0100.0175.90
4.4.50.0100.0205.80
4.4.40.0000.0435.79
4.4.30.0030.0235.79
4.4.20.0070.0205.94
4.4.10.0100.0205.94
4.4.00.0030.0375.88
4.3.110.0070.0205.80
4.3.100.0070.0275.71
4.3.90.0070.0175.77
4.3.80.0000.0405.76
4.3.70.0000.0275.69
4.3.60.0100.0175.69
4.3.50.0000.0275.70
4.3.40.0000.0435.67
4.3.30.0030.0275.48
4.3.20.0100.0175.51
4.3.10.0030.0235.51
4.3.00.0100.0135.51

preferences:
82.93 ms | 401 KiB | 5 Q