3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * How to get a json array of the text within a class? * * @link http://stackoverflow.com/a/23543493/367456 */ $html = '<body>... <th class="name" align="left" scope="col"> <a class="foo" href="foo.html">foo</a> </th> ... <th class="name" align="left" scope="col"> <a class="bar" href="bar.html">bar</a> </th> ... <th class="name" align="left" scope="col"> <a class="ba" href="baz.html">baz</a> </th></body>'; $names = function($html) { $doc = new DOMDocument(); $last = libxml_use_internal_errors(TRUE); $doc->loadHTML($html); libxml_use_internal_errors($last); $xp = new DOMXPath($doc); $result = array(); foreach ($xp->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' name ')]") as $node) $result[trim($node->textContent)] = 1; return array_keys($result); }; echo json_encode(array("names" => $names($html)));

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.0120.00318.56
8.3.50.0130.00822.25
8.3.40.0070.00719.00
8.3.30.0130.00319.46
8.3.20.0040.00420.72
8.3.10.0090.00022.21
8.3.00.0000.00820.83
8.2.180.0040.01216.88
8.2.170.0090.01222.96
8.2.160.0090.00921.25
8.2.150.0050.00325.66
8.2.140.0150.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00020.27
8.2.110.0070.00322.75
8.2.100.0080.00418.16
8.2.90.0000.00819.55
8.2.80.0040.00419.66
8.2.70.0060.00317.88
8.2.60.0090.00018.30
8.2.50.0080.00018.07
8.2.40.0060.00318.72
8.2.30.0040.00418.42
8.2.20.0000.00818.04
8.2.10.0090.00019.73
8.2.00.0050.00518.16
8.1.280.0140.00425.92
8.1.270.0000.00822.57
8.1.260.0000.00926.35
8.1.250.0050.00328.09
8.1.240.0090.00324.23
8.1.230.0080.00418.04
8.1.220.0030.00618.15
8.1.210.0030.00618.77
8.1.200.0000.01117.72
8.1.190.0030.00517.86
8.1.180.0040.00418.10
8.1.170.0000.00818.96
8.1.160.0050.00322.29
8.1.150.0070.00018.99
8.1.140.0060.00317.85
8.1.130.0000.00718.11
8.1.120.0040.00417.84
8.1.110.0050.00217.80
8.1.100.0000.00717.70
8.1.90.0040.00417.75
8.1.80.0000.00717.84
8.1.70.0030.00317.76
8.1.60.0060.00317.93
8.1.50.0000.00917.76
8.1.40.0030.00617.80
8.1.30.0030.00517.96
8.1.20.0050.00317.97
8.1.10.0030.00518.02
8.1.00.0000.00817.92
8.0.300.0050.00518.77
8.0.290.0050.00317.25
8.0.280.0030.00318.69
8.0.270.0000.00717.65
8.0.260.0000.00817.15
8.0.250.0030.00717.30
8.0.240.0000.00717.29
8.0.230.0040.00417.18
8.0.220.0000.00717.18
8.0.210.0000.00717.18
8.0.200.0000.00717.26
8.0.190.0040.00417.31
8.0.180.0000.00717.20
8.0.170.0070.00017.32
8.0.160.0030.00617.33
8.0.150.0040.00417.09
8.0.140.0040.00417.25
8.0.130.0030.00313.69
8.0.120.0070.00017.14
8.0.110.0040.00417.27
8.0.100.0070.00017.30
8.0.90.0040.00417.22
8.0.80.0060.01017.16
8.0.70.0000.00717.22
8.0.60.0000.00717.14
8.0.50.0040.00417.38
8.0.30.0130.00917.53
8.0.20.0120.00717.55
8.0.10.0050.00317.20
8.0.00.0120.00617.07
7.4.330.0030.00315.40
7.4.320.0000.00716.87
7.4.300.0070.00016.83
7.4.290.0060.00316.95
7.4.280.0030.00317.01
7.4.270.0060.00317.01
7.4.260.0000.00716.95
7.4.250.0060.00316.94
7.4.240.0030.00516.87
7.4.230.0080.00016.73
7.4.220.0130.01316.85
7.4.210.0110.00416.96
7.4.200.0000.00716.92
7.4.190.0050.00316.84
7.4.160.0130.00316.67
7.4.150.0140.00417.40
7.4.140.0120.00817.86
7.4.130.0120.00716.91
7.4.120.0130.00416.83
7.4.110.0090.00916.80
7.4.100.0090.00816.81
7.4.90.0090.00917.00
7.4.80.0140.01019.39
7.4.70.0130.00316.90
7.4.60.0100.00716.77
7.4.50.0000.00516.70
7.4.40.0070.01122.77
7.4.30.0120.00616.92
7.4.00.0030.01015.03
7.3.330.0050.00013.51
7.3.320.0060.00013.32
7.3.310.0070.00016.55
7.3.300.0030.00316.66
7.3.290.0100.01016.63
7.3.280.0110.00716.61
7.3.270.0070.01117.40
7.3.260.0110.01116.75
7.3.250.0070.01016.77
7.3.240.0040.01816.69
7.3.230.0120.01316.80
7.3.210.0140.00316.50
7.3.200.0100.01319.39
7.3.190.0090.00916.71
7.3.180.0060.00916.71
7.3.170.0160.00017.01
7.3.160.0030.01316.63
7.3.120.0090.00615.28
7.2.330.0100.01017.00
7.2.320.0090.00917.18
7.2.310.0130.00317.10
7.2.300.0130.00916.85
7.2.290.0090.00916.85
7.2.110.0180.00416.84
7.2.60.0100.00617.15
7.1.200.0070.00315.95
7.1.70.0040.01116.97
7.1.60.0070.01819.82
7.1.50.0070.01616.91
7.1.00.0030.07722.55
7.0.200.0210.00016.77
7.0.140.0030.07722.14
7.0.90.0030.08720.10
7.0.80.0600.08319.99
7.0.70.0130.07319.95
7.0.60.0070.08720.02
7.0.50.0030.06320.49
7.0.40.0100.07720.27
7.0.30.0070.08320.27
7.0.20.0070.05020.19
7.0.10.0000.07320.20
7.0.00.0000.04320.17
5.6.280.0070.07321.08
5.6.240.0170.05020.76
5.6.230.0070.08020.75
5.6.220.0070.06020.77
5.6.210.0130.06720.79
5.6.200.0100.09721.21
5.6.190.0000.08021.21
5.6.180.0130.07721.16
5.6.170.0070.07721.17
5.6.160.0030.09021.26
5.6.150.0070.08021.13
5.6.140.0030.04321.13
5.6.130.0030.08721.25
5.6.120.0070.04721.20
5.6.110.0030.08021.25
5.6.100.0070.04021.27
5.6.90.0130.08021.16
5.6.80.0030.08720.62
5.6.70.0100.09320.54
5.6.60.0130.07320.67
5.6.50.0130.04020.54
5.6.40.0000.09320.41
5.6.30.0200.06720.55
5.6.20.0000.05320.48
5.6.10.0070.04320.60
5.6.00.0130.08020.56
5.5.380.0070.09020.49
5.5.370.0100.05020.47
5.5.360.0030.08320.68
5.5.350.0070.07020.61
5.5.340.0170.04320.99
5.5.330.0070.04721.02
5.5.320.0100.04720.93
5.5.310.0030.08021.02
5.5.300.0030.06720.95
5.5.290.0070.04321.02
5.5.280.0070.08321.05
5.5.270.0100.08021.02
5.5.260.0030.08321.01
5.5.250.0130.07720.77
5.5.240.0130.07020.32
5.5.230.0030.04720.39
5.5.220.0100.06020.14
5.5.210.0130.06720.42
5.5.200.0030.07720.37
5.5.190.0100.04320.27
5.5.180.0130.03320.39
5.5.160.0130.07320.27
5.5.150.0070.08320.28
5.5.140.0130.07320.36
5.5.130.0000.05020.36
5.5.120.0130.07320.36
5.5.110.0130.07020.38
5.5.100.0070.08320.29
5.5.90.0100.08020.25
5.5.80.0070.08020.26
5.5.70.0130.07320.27
5.5.60.0070.07720.19
5.5.50.0130.04320.26
5.5.40.0070.07320.27
5.5.30.0070.04320.23
5.5.20.0100.06720.26
5.5.10.0100.07320.18
5.5.00.0100.07320.17
5.4.450.0100.05019.70
5.4.440.0100.08019.61
5.4.430.0100.03019.38
5.4.420.0130.08019.50
5.4.410.0100.07319.47
5.4.400.0030.05719.36
5.4.390.0030.07319.38
5.4.380.0100.06019.28
5.4.370.0070.07019.29
5.4.360.0100.06719.07
5.4.350.0070.04319.27
5.4.340.0030.07319.36
5.4.320.0030.05019.26
5.4.310.0100.04319.26
5.4.300.0070.04719.06
5.4.290.0070.06719.08
5.4.280.0070.05319.30
5.4.270.0130.07019.31
5.4.260.0100.06319.06
5.4.250.0170.07019.20
5.4.240.0200.06319.36
5.4.230.0070.06319.19
5.4.220.0030.04319.28
5.4.210.0100.07719.25
5.4.200.0100.06719.27
5.4.190.0200.06719.32
5.4.180.0070.09319.25
5.4.170.0070.07719.25
5.4.160.0070.08019.25
5.4.150.0070.04719.05
5.4.140.0100.07316.65
5.4.130.0100.03016.46
5.4.120.0070.04016.58
5.4.110.0100.07316.71
5.4.100.0030.04716.61
5.4.90.0070.05016.60
5.4.80.0000.06316.72
5.4.70.0030.03716.65
5.4.60.0100.04716.57
5.4.50.0100.05716.73
5.4.40.0100.05716.71
5.4.30.0000.04316.62
5.4.20.0070.06716.61
5.4.10.0100.07016.62
5.4.00.0030.05016.07
5.3.290.0070.07714.85
5.3.280.0030.07314.88
5.3.270.0030.07014.82
5.3.260.0230.03714.84
5.3.250.0030.07314.75
5.3.240.0100.07314.93
5.3.230.0030.04714.75
5.3.220.0070.05014.82
5.3.210.0130.06314.79
5.3.200.0030.08014.71
5.3.190.0070.07714.75
5.3.180.0130.07014.79
5.3.170.0030.04714.89
5.3.160.0130.07014.65
5.3.150.0130.07014.65
5.3.140.0070.04314.83
5.3.130.0030.08314.63
5.3.120.0070.06714.64
5.3.110.0000.05014.82
5.3.100.0070.03714.25
5.3.90.0030.06714.20
5.3.80.0070.06314.14
5.3.70.0030.08014.14
5.3.60.0070.06314.27
5.3.50.0100.07314.17
5.3.40.0070.07714.08
5.3.30.0030.07014.18
5.3.20.0100.04313.94
5.3.10.0000.07313.79
5.3.00.0000.07313.84
5.2.170.0030.06311.16
5.2.160.0070.04311.10
5.2.150.0000.06710.95
5.2.140.0030.05310.99
5.2.130.0000.03310.96
5.2.120.0100.05311.08
5.2.110.0100.05311.10
5.2.100.0030.04011.09
5.2.90.0130.03711.17
5.2.80.0000.03311.12
5.2.70.0070.05711.11
5.2.60.0100.05011.10
5.2.50.0130.05710.97
5.2.40.0100.05711.05
5.2.30.0000.07010.81
5.2.20.0030.05710.83
5.2.10.0070.06010.81
5.2.00.0000.04010.61
5.1.60.0070.02710.01
5.1.50.0070.0539.84
5.1.40.0100.0479.97
5.1.30.0000.06010.39
5.1.20.0030.05710.40
5.1.10.0000.04310.15
5.1.00.0030.05710.12
5.0.50.0030.0508.59
5.0.40.0000.0308.45
5.0.30.0030.0638.25
5.0.20.0030.0438.27
5.0.10.0070.0378.25
5.0.00.0000.0508.21
4.4.90.0030.0377.60
4.4.80.0030.0177.60
4.4.70.0000.0307.60
4.4.60.0070.0337.60
4.4.50.0000.0377.60
4.4.40.0030.0607.60
4.4.30.0030.0177.60
4.4.20.0000.0377.60
4.4.10.0030.0377.60
4.4.00.0070.0507.60
4.3.110.0000.0177.60
4.3.100.0070.0307.60
4.3.90.0000.0277.60
4.3.80.0070.0507.60
4.3.70.0000.0277.60
4.3.60.0070.0307.60
4.3.50.0030.0377.60
4.3.40.0030.0307.60
4.3.30.0030.0237.60
4.3.20.0030.0337.60
4.3.10.0000.0277.60
4.3.00.0030.0237.60

preferences:
42.84 ms | 401 KiB | 5 Q