3v4l.org

run code in 300+ PHP versions simultaneously
<?php class BookXML extends \DOMDocument { public function filterByYear(int $year) { $books = []; $document = $this; $xpath = new DOMXPath($document); $booksObjs = $document->documentElement; $query = 'string(year)'; foreach ($booksObjs->childNodes as $booksObj) { $yearxml = $xpath->evaluate($query, $booksObj); if ($yearxml == $year) { $books[] = $booksObj; } } return $books; } } $content = ' <xml> <row> <year>2015</year> <month>september</month> </row> </xml> '; $xml = new BookXML(); $xml->loadXML($content); $filteredXML = $xml->filterByYear(2015); print_r($filteredXML);

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.140.0120.01018.12
8.4.130.0050.00518.01
8.4.120.0150.00520.95
8.4.110.0110.00919.50
8.4.100.0150.00617.91
8.4.90.0110.01021.09
8.4.80.0130.00719.25
8.4.70.0120.00819.31
8.4.60.0110.00621.11
8.4.50.0030.00520.51
8.4.40.0090.00018.15
8.4.30.0100.01021.02
8.4.20.0120.00619.18
8.4.10.0080.00020.81
8.3.270.0160.00916.78
8.3.260.0110.00816.80
8.3.250.0130.00619.48
8.3.240.0030.00717.14
8.3.230.0060.00516.82
8.3.220.0100.00919.48
8.3.210.0140.00518.82
8.3.200.0060.00316.89
8.3.190.0080.00919.29
8.3.180.0030.00518.93
8.3.170.0070.01119.11
8.3.160.0110.00420.67
8.3.150.0090.00917.33
8.3.140.0000.01817.56
8.3.130.0000.01618.62
8.3.120.0080.00821.27
8.3.110.0070.00316.86
8.3.100.0130.00317.10
8.3.90.0080.00026.77
8.3.80.0000.01117.00
8.3.70.0120.00916.87
8.3.60.0150.00318.80
8.3.50.0110.01123.83
8.3.40.0040.01818.77
8.3.30.0150.00019.04
8.3.20.0000.00724.18
8.3.10.0080.00024.66
8.3.00.0000.00826.16
8.2.290.0110.00817.13
8.2.280.0100.00918.80
8.2.270.0050.00319.42
8.2.260.0050.00317.05
8.2.250.0040.00417.84
8.2.240.0050.00517.04
8.2.230.0080.00820.94
8.2.220.0090.00024.06
8.2.210.0000.00726.77
8.2.200.0090.00017.00
8.2.190.0070.01717.13
8.2.180.0070.00725.92
8.2.170.0120.00319.29
8.2.160.0070.01322.96
8.2.150.0050.00225.66
8.2.140.0030.00524.66
8.2.130.0030.00526.16
8.2.120.0000.00826.35
8.2.110.0040.00721.36
8.2.100.0130.00618.12
8.2.90.0040.00418.13
8.2.80.0080.00018.98
8.2.70.0030.00718.18
8.2.60.0090.00018.59
8.2.50.0080.00018.10
8.2.40.0060.00319.84
8.2.30.0000.00719.51
8.2.20.0040.00418.39
8.2.10.0040.00419.59
8.2.00.0060.00319.76
8.1.330.0120.00424.07
8.1.320.0100.01016.40
8.1.310.0040.00418.69
8.1.300.0100.00018.12
8.1.290.0050.00530.84
8.1.280.0120.00625.92
8.1.270.0110.00423.99
8.1.260.0040.00428.09
8.1.250.0060.00328.09
8.1.240.0030.00621.41
8.1.230.0040.00817.95
8.1.220.0040.00418.16
8.1.210.0080.00018.77
8.1.200.0090.00017.60
8.1.190.0060.00317.47
8.1.180.0060.00318.10
8.1.170.0040.00418.95
8.1.160.0000.00719.42
8.1.150.0030.00519.37
8.1.140.0040.00419.30
8.1.130.0030.00320.37
8.1.120.0060.00317.70
8.1.110.0000.00717.91
8.1.100.0030.00617.77
8.1.90.0050.00317.79
8.1.80.0000.00717.73
8.1.70.0040.00417.88
8.1.60.0060.00317.82
8.1.50.0040.00417.74
8.1.40.0040.00417.98
8.1.30.0030.00618.00
8.1.20.0030.00517.94
8.1.10.0040.00418.01
8.1.00.0050.00217.76
8.0.300.0080.00018.77
8.0.290.0000.00817.13
8.0.280.0000.00718.78
8.0.270.0080.00017.25
8.0.260.0030.00518.83
8.0.250.0000.00717.40
8.0.240.0060.00017.17
8.0.230.0030.00317.14
8.0.220.0030.00317.30
8.0.210.0070.00017.29
8.0.200.0000.00817.21
8.0.190.0070.00017.25
8.0.180.0030.00517.39
8.0.170.0060.00317.23
8.0.160.0040.00417.34
8.0.150.0040.00417.24
8.0.140.0030.00617.08
8.0.130.0000.00513.60
8.0.120.0030.00717.30
8.0.110.0040.00417.30
8.0.100.0000.00817.23
8.0.90.0000.00817.24
8.0.80.0030.01317.18
8.0.70.0050.00317.37
8.0.60.0070.00317.20
8.0.50.0000.00717.16
8.0.30.0100.01417.51
8.0.20.0020.01617.32
8.0.10.0000.00717.34
8.0.00.0140.00717.13
7.4.330.0050.00015.55
7.4.320.0030.00316.85
7.4.300.0030.00316.99
7.4.290.0000.00916.97
7.4.280.0000.00716.79
7.4.270.0030.00316.68
7.4.260.0060.00013.50
7.4.250.0000.00816.85
7.4.240.0070.00016.93
7.4.230.0050.00216.90
7.4.220.0030.00316.94
7.4.210.0080.00717.00
7.4.200.0000.00716.79
7.4.130.0090.00816.85
7.4.120.0120.01616.90
7.4.110.0150.00316.73
7.4.100.0090.00916.84
7.4.90.0070.01116.69
7.4.80.0240.01516.73
7.4.70.0240.01516.83
7.4.60.0260.01216.77
7.4.50.0320.00816.81
7.4.40.0330.00516.84
7.4.30.0360.00616.77
7.4.20.0320.01016.89
7.4.10.0290.01016.61
7.4.00.0170.00816.77
7.3.330.0070.00016.77
7.3.320.0050.00013.30
7.3.310.0030.00516.44
7.3.300.0000.00716.59
7.3.290.0090.00816.64
7.3.280.0030.01316.64
7.3.260.0150.00316.74
7.3.230.0070.01016.67
7.3.210.0030.01516.64
7.3.200.0290.00916.81
7.3.190.0300.01316.85
7.3.180.0330.00916.48
7.3.170.0350.00616.89
7.3.160.0210.01616.83
7.3.150.0340.00716.86
7.3.140.0270.01716.61
7.3.130.0300.01316.64
7.3.120.0280.01216.88
7.3.110.0320.00716.85
7.3.100.0290.00916.75
7.3.90.0150.02316.72
7.3.80.0280.01316.61
7.3.70.0280.00516.72
7.3.60.0240.01516.79
7.3.50.0310.00916.77
7.3.40.0240.01216.68
7.3.30.0280.01016.75
7.3.20.0260.01016.87
7.3.10.0280.01216.71
7.3.00.0300.01116.74
7.2.330.0060.01217.13
7.2.320.0190.01716.86
7.2.310.0200.01716.88
7.2.300.0350.00516.79
7.2.290.0320.01116.99
7.2.280.0300.00917.18
7.2.270.0270.01616.97
7.2.260.0290.01117.11
7.2.250.0280.01317.15
7.2.240.0280.01216.79
7.2.230.0270.01616.96
7.2.220.0330.00616.64
7.2.210.0240.01416.93
7.2.200.0260.01316.75
7.2.190.0320.00916.95
7.2.180.0290.01216.98
7.2.170.0220.01916.92
7.2.160.0330.00617.11
7.2.150.0320.01417.23
7.2.140.0400.00017.02
7.2.130.0380.01217.19
7.2.120.0290.01317.09
7.2.110.0340.00716.98
7.2.100.0280.01416.93
7.2.90.0400.00016.97
7.2.80.0170.02017.04
7.2.70.0270.01016.98
7.2.60.0270.01417.00
7.2.50.0340.01016.98
7.2.40.0210.02217.03
7.2.30.0270.00617.00
7.2.20.0260.00516.89
7.2.10.0240.00616.89
7.2.00.0140.02016.70

preferences:
30.67 ms | 403 KiB | 5 Q