3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<XML <cats> <cat> <name>Jack</name> <age>2</age> <color>grey</color> <color>white</color> </cat> <cat> <name>Maxwell</name> <age>12</age> <color>orange</color> <color>black</color> </cat> </cats> XML; function xml2array($fname){ $sxi = new SimpleXmlIterator($fname, null, true); return sxiToArray($sxi); } function sxiToArray($sxi){ $a = array(); for( $sxi->rewind(); $sxi->valid(); $sxi->next() ) { if(!array_key_exists($sxi->key(), $a)){ $a[$sxi->key()] = array(); } if($sxi->hasChildren()){ $a[$sxi->key()][] = sxiToArray($sxi->current()); } else{ $a[$sxi->key()][] = strval($sxi->current()); } } return $a; } // Read cats.xml and print the results: $catArray = xml2array($xml); print_r($catArray); ?>

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.0070.01117.13
8.3.50.0140.00322.05
8.3.40.0090.00619.00
8.3.30.0030.01218.94
8.3.20.0040.00420.33
8.3.10.0040.00423.83
8.3.00.0040.00419.51
8.2.180.0120.00318.43
8.2.170.0120.00322.96
8.2.160.0110.00320.65
8.2.150.0060.00324.18
8.2.140.0090.00024.66
8.2.130.0090.00019.26
8.2.120.0030.00626.35
8.2.110.0100.00021.31
8.2.100.0060.00617.75
8.2.90.0030.00519.17
8.2.80.0000.00817.97
8.2.70.0050.00317.63
8.2.60.0070.00417.80
8.2.50.0000.00918.07
8.2.40.0030.00519.47
8.2.30.0070.00020.69
8.2.20.0030.00617.80
8.2.10.0000.00818.21
8.2.00.0000.00818.38
8.1.280.0070.01025.92
8.1.270.0150.00423.79
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0110.00721.36
8.1.230.0060.00617.77
8.1.220.0040.00417.74
8.1.210.0030.00918.77
8.1.200.0060.00317.48
8.1.190.0080.00017.79
8.1.180.0040.00418.10
8.1.170.0080.00018.78
8.1.160.0040.00422.03
8.1.150.0000.00818.89
8.1.140.0080.00019.60
8.1.130.0000.00717.73
8.1.120.0000.00817.36
8.1.110.0040.00417.58
8.1.100.0000.00717.55
8.1.90.0030.00517.57
8.1.80.0040.00417.37
8.1.70.0030.00317.55
8.1.60.0040.00417.71
8.1.50.0000.00817.57
8.1.40.0030.00517.70
8.1.30.0000.00817.65
8.1.20.0030.00617.71
8.1.10.0000.00917.74
8.1.00.0040.00417.66
8.0.300.0040.00418.77
8.0.290.0000.00916.88
8.0.280.0070.00018.46
8.0.270.0040.00417.32
8.0.260.0000.00617.25
8.0.250.0030.00316.95
8.0.240.0040.00417.09
8.0.230.0000.00817.02
8.0.220.0100.00017.11
8.0.210.0030.00717.03
8.0.200.0000.00816.92
8.0.190.0030.00516.90
8.0.180.0080.00017.10
8.0.170.0050.00517.07
8.0.160.0040.00417.00
8.0.150.0050.00517.01
8.0.140.0040.00416.88
8.0.130.0000.00613.52
8.0.120.0000.00817.00
8.0.110.0080.00016.79
8.0.100.0080.00016.99
8.0.90.0000.00716.96
8.0.80.0130.01017.03
8.0.70.0040.00416.96
8.0.60.0050.00316.99
8.0.50.0040.00417.00
8.0.30.0120.00617.37
8.0.20.0130.01017.45
8.0.10.0000.00717.18
8.0.00.0060.01216.94
7.4.330.0000.00616.84
7.4.320.0000.00716.55
7.4.300.0030.00316.64
7.4.290.0080.00016.49
7.4.280.0000.00716.70
7.4.270.0000.00716.82
7.4.260.0060.00316.75
7.4.250.0070.00016.70
7.4.240.0010.00616.67
7.4.230.0040.00416.66
7.4.220.0100.01016.79
7.4.210.0110.00716.74
7.4.200.0000.00816.68
7.4.160.0040.01416.52
7.4.150.0200.02417.40
7.4.140.0110.00817.86
7.4.130.0090.01216.67
7.4.120.0080.01316.68
7.4.110.0090.00916.74
7.4.100.0130.00616.66
7.4.90.0090.00916.60
7.4.80.0100.00719.39
7.4.70.0130.00916.74
7.4.60.0040.01216.62
7.4.50.0030.01316.51
7.4.40.0180.00316.80
7.4.30.0030.01316.71
7.4.10.0070.01314.99
7.4.00.0060.01214.90
7.3.330.0020.00213.31
7.3.320.0050.00013.38
7.3.310.0050.00316.30
7.3.300.0070.00016.31
7.3.290.0040.00416.46
7.3.280.0120.00616.34
7.3.270.0110.01117.40
7.3.260.0060.01616.39
7.3.250.0110.00716.51
7.3.240.0110.00916.49
7.3.230.0070.01116.61
7.3.210.0100.00716.54
7.3.200.0100.00616.64
7.3.190.0070.01716.48
7.3.180.0110.00716.64
7.3.170.0090.00916.50
7.3.160.0030.01316.44
7.3.130.0070.01014.95
7.3.120.0070.01114.86
7.3.110.0110.00614.86
7.3.100.0090.00914.89
7.3.90.0070.00814.84
7.3.80.0090.00514.74
7.3.70.0050.00814.80
7.3.60.0080.00714.69
7.3.50.0030.00914.76
7.3.40.0040.00914.83
7.3.30.0010.01014.77
7.3.20.0010.00916.78
7.3.10.0020.00816.63
7.3.00.0100.00316.78
7.2.330.0110.00716.78
7.2.320.0090.01216.64
7.2.310.0090.00916.64
7.2.300.0110.01116.52
7.2.290.0130.01016.58
7.2.260.0110.00714.68
7.2.250.0090.01015.11
7.2.240.0050.01214.98
7.2.230.0070.00914.88
7.2.220.0070.00814.79
7.2.210.0040.00914.92
7.2.200.0030.01014.90
7.2.190.0100.00214.94
7.2.180.0040.01114.70
7.2.170.0060.00814.94
7.2.160.0100.00314.94
7.2.150.0040.00816.61
7.2.140.0000.01616.61
7.2.130.0110.00716.84
7.2.120.0070.00716.70
7.2.110.0030.00916.65
7.2.100.0070.00716.62
7.2.90.0100.00616.89
7.2.80.0080.00616.91
7.2.70.0030.00916.80
7.2.60.0050.01016.78
7.2.50.0040.01116.85
7.2.40.0030.00716.89
7.2.30.0070.00716.82
7.2.20.0080.00316.92
7.2.10.0070.00716.61
7.2.00.0090.00517.98
7.1.330.0070.00815.72
7.1.320.0070.00715.85
7.1.310.0070.00615.79
7.1.300.0070.00615.60
7.1.290.0040.00715.69
7.1.280.0060.00915.81
7.1.270.0030.01215.65
7.1.260.0090.00415.61
7.1.250.0080.00415.76
7.1.240.0000.01715.64
7.1.230.0060.00615.59
7.1.220.0030.00615.67
7.1.210.0070.00715.48
7.1.200.0010.00615.63
7.1.190.0060.00615.55
7.1.180.0030.01015.70
7.1.170.0030.01115.59
7.1.160.0030.01315.69
7.1.150.0070.00415.64
7.1.140.0090.00615.63
7.1.130.0120.00015.70
7.1.120.0090.00315.67
7.1.110.0060.00915.77
7.1.100.0050.00517.04
7.1.90.0090.00015.53
7.1.80.0060.00615.59
7.1.70.0050.00716.33
7.1.60.0080.01117.53
7.1.50.0020.01816.38
7.1.40.0030.01015.50
7.1.30.0030.01015.69
7.1.20.0100.00015.69
7.1.10.0130.00015.75
7.1.00.0060.04319.01
7.0.330.0000.01415.40
7.0.320.0030.01015.32
7.0.310.0080.00015.39
7.0.300.0030.00615.35
7.0.290.0060.00615.14
7.0.280.0000.00815.38
7.0.270.0040.00815.35
7.0.260.0000.01215.41
7.0.250.0030.01015.21
7.0.240.0050.00315.26
7.0.230.0080.00015.53
7.0.220.0030.00615.09
7.0.210.0000.00915.20
7.0.200.0060.00615.99
7.0.190.0070.00715.58
7.0.180.0030.00615.36
7.0.170.0060.01015.38
7.0.160.0030.01015.39
7.0.150.0070.00415.43
7.0.140.0090.00615.40
7.0.130.0030.01415.43
7.0.120.0040.01215.29
7.0.110.0060.00615.19
7.0.100.0070.04317.58
7.0.90.0130.03817.78
7.0.80.0100.04617.65
7.0.70.0100.04217.60
7.0.60.0080.03617.66
7.0.50.0130.04217.78
7.0.40.0130.04016.78
7.0.30.0090.03816.74
7.0.20.0050.04316.78
7.0.10.0080.04216.82
7.0.00.0070.03916.76
5.6.400.0040.01114.24
5.6.390.0060.00914.37
5.6.380.0060.00314.02
5.6.370.0060.00914.54
5.6.360.0060.00314.43
5.6.350.0000.01114.30
5.6.340.0060.00914.13
5.6.330.0050.00514.25
5.6.320.0090.00614.36
5.6.310.0060.00614.36
5.6.300.0100.01014.55
5.6.290.0090.00914.40
5.6.280.0040.02317.77
5.6.270.0030.01014.42
5.6.260.0080.00814.47
5.6.250.0100.04017.58
5.6.240.0080.04517.53
5.6.230.0060.04417.29
5.6.220.0030.04317.47
5.6.210.0120.04017.52
5.6.200.0100.04217.66
5.6.190.0080.04617.69
5.6.180.0130.04117.75
5.6.170.0080.04017.67
5.6.160.0060.04517.80
5.6.150.0150.03617.69
5.6.140.0080.03917.69
5.6.130.0080.04017.68
5.6.120.0030.04717.64
5.6.110.0050.04517.78
5.6.100.0130.03517.62
5.6.90.0030.04717.62
5.6.80.0060.04117.23
5.6.70.0050.04717.49
5.6.60.0070.04417.24
5.6.50.0060.04517.17
5.6.40.0110.02817.34
5.6.30.0050.04217.32
5.6.20.0050.04117.29
5.6.10.0100.03417.28
5.6.00.0100.04117.31
5.5.380.0030.04817.39
5.5.370.0080.04317.36
5.5.360.0050.05017.32
5.5.350.0140.03717.22
5.5.340.0130.03817.65
5.5.330.0110.04017.38
5.5.320.0050.04617.39
5.5.310.0100.04017.57
5.5.300.0070.04517.46
5.5.290.0030.04617.61
5.5.280.0030.04817.63
5.5.270.0100.04317.57
5.5.260.0080.03017.46
5.5.250.0100.04317.48
5.5.240.0050.02817.18
5.5.230.0100.04117.15
5.5.220.0090.04317.01
5.5.210.0060.04417.02
5.5.200.0030.03017.13
5.5.190.0070.04217.21
5.5.180.0130.04016.91
5.5.170.0040.01113.71
5.5.160.0080.04117.12
5.5.150.0090.03017.26
5.5.140.0020.05117.02
5.5.130.0060.04117.11
5.5.120.0050.03717.20
5.5.110.0050.03017.16
5.5.100.0070.04017.22
5.5.90.0050.04417.17
5.5.80.0100.04017.09
5.5.70.0050.03217.20
5.5.60.0060.04117.04
5.5.50.0060.04117.01
5.5.40.0030.03017.08
5.5.30.0080.03916.98
5.5.20.0090.03617.10
5.5.10.0030.04817.16
5.5.00.0090.03817.09

preferences:
49.54 ms | 401 KiB | 5 Q