3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<p>random</p> <a href="">Test 1</a> (target1) <br> <a href="">Test 2</a> (target2) <br> <a href="">Test 3</a> (skip) // etc '; $array = array( '(target1)', '(target2)' ); $contains = implode(" or ", array_map(function($x) { return "contains(., '$x')"; }, $array)); $doc = new DOMDocument(); $doc->loadHTML('<?xml encoding="utf-8" ?>' . $html); $xpath = new DOMXPath($doc); $elements = $xpath->query("//a/following-sibling::text()[$contains]"); $results = []; foreach ($elements as $element) { $results[] = [$element->previousSibling->nodeValue, trim($element->nodeValue)]; } print_r($results);

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.0160.00018.68
8.3.50.0070.01118.70
8.3.40.0130.00619.24
8.3.30.0150.00019.22
8.3.20.0080.00819.45
8.3.10.0060.00323.96
8.3.00.0040.00422.86
8.2.180.0120.00918.64
8.2.170.0120.00322.96
8.2.160.0110.00321.52
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0050.00226.16
8.2.120.0030.00621.08
8.2.110.0070.00422.75
8.2.100.0080.00418.06
8.2.90.0000.00818.00
8.2.80.0050.00317.97
8.2.70.0030.00518.30
8.2.60.0000.00818.41
8.2.50.0040.00418.10
8.2.40.0000.00821.43
8.2.30.0040.00420.91
8.2.20.0060.00318.37
8.2.10.0040.00418.54
8.2.00.0070.00019.77
8.1.280.0120.00325.92
8.1.270.0110.00422.41
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0040.00424.16
8.1.230.0060.00619.41
8.1.220.0000.00818.03
8.1.210.0060.00318.77
8.1.200.0030.00717.63
8.1.190.0030.00617.48
8.1.180.0000.00818.10
8.1.170.0050.00319.09
8.1.160.0040.00419.25
8.1.150.0040.00419.16
8.1.140.0040.00419.31
8.1.130.0030.00319.47
8.1.120.0040.00417.78
8.1.110.0000.01017.83
8.1.100.0050.00317.84
8.1.90.0040.00417.86
8.1.80.0000.00817.68
8.1.70.0040.00417.82
8.1.60.0040.00417.95
8.1.50.0040.00417.75
8.1.40.0030.00617.91
8.1.30.0060.00317.89
8.1.20.0000.00717.99
8.1.10.0000.00817.81
8.1.00.0040.00417.77
8.0.300.0040.00419.91
8.0.290.0030.00616.98
8.0.280.0020.00518.77
8.0.270.0040.00417.58
8.0.260.0030.00618.90
8.0.250.0000.01117.30
8.0.240.0040.00417.27
8.0.230.0070.00017.30
8.0.220.0000.00817.23
8.0.210.0000.00717.23
8.0.200.0000.00717.27
8.0.190.0030.00517.31
8.0.180.0080.00017.20
8.0.170.0000.00917.27
8.0.160.0000.00817.19
8.0.150.0070.00017.20
8.0.140.0040.00417.06
8.0.130.0060.00013.69
8.0.120.0040.00417.16
8.0.110.0040.00417.09
8.0.100.0070.00017.13
8.0.90.0050.00217.20
8.0.80.0080.01217.20
8.0.70.0030.00317.20
8.0.60.0000.00717.00
8.0.50.0070.00017.17
8.0.30.0100.01017.34
8.0.20.0150.00417.57
8.0.10.0050.00217.25
8.0.00.0100.00817.21
7.4.330.0050.00015.55
7.4.320.0000.00716.98
7.4.300.0060.00016.88
7.4.290.0000.00716.95
7.4.280.0050.00316.79
7.4.270.0000.00716.94
7.4.260.0040.00416.92
7.4.250.0000.00716.76
7.4.240.0030.00316.75
7.4.230.0030.00316.74
7.4.220.0040.00417.04
7.4.210.0080.00616.80
7.4.200.0070.00016.70
7.4.160.0100.00716.68
7.4.140.0080.01317.86
7.4.130.0120.00616.71
7.4.120.0060.01116.92
7.4.110.0030.01316.96
7.4.100.0100.01316.82
7.4.90.0110.00816.86
7.4.80.0130.00319.39
7.4.70.0020.01117.06
7.4.60.0050.01016.64
7.4.50.0030.01416.80
7.4.40.0180.00016.75
7.4.00.0060.00915.25
7.3.330.0000.00613.55
7.3.320.0030.00313.66
7.3.310.0000.00716.66
7.3.300.0030.00316.68
7.3.290.0050.00216.58
7.3.280.0060.01316.65
7.3.260.0090.01016.86
7.3.240.0140.00516.90
7.3.230.0070.01016.98
7.3.210.0070.01416.61
7.3.200.0130.00616.96
7.3.190.0030.01316.99
7.3.180.0060.01216.88
7.3.170.0110.00616.84
7.3.160.0060.01116.98
7.3.10.0110.00216.78
7.3.00.0070.00916.55
7.2.330.0170.00916.88
7.2.320.0070.01116.86
7.2.310.0090.00917.25
7.2.300.0090.00817.07
7.2.290.0100.01316.99
7.2.130.0070.01017.10
7.2.120.0080.00316.96
7.2.110.0050.00817.18
7.2.100.0050.00517.10
7.2.90.1030.00916.50
7.2.80.0920.00916.33
7.2.70.1210.00716.49
7.2.60.0900.00716.46
7.2.50.0510.00816.41
7.2.40.0510.00716.34
7.2.30.1000.00816.46
7.2.20.0700.00816.46
7.2.10.1080.00616.31
7.2.00.0570.00716.47
7.1.250.0020.00916.15
7.1.210.3220.00914.20
7.1.200.2400.01013.93
7.1.190.1830.01314.18
7.1.180.1690.01013.78
7.1.170.1370.01014.30
7.1.160.2810.00713.82
7.1.150.3370.00614.15
7.1.140.2770.01013.86
7.1.130.2590.01013.48
7.1.120.1470.01014.11
7.1.110.0970.00313.94
7.1.100.0190.00314.14
7.1.90.0540.00813.68
7.1.80.0410.00613.84
7.1.70.0000.01913.95
7.1.60.0280.01531.68
7.1.50.0290.01632.11
7.1.40.0770.01132.05
7.1.30.0260.01331.86
7.1.20.0390.02232.17
7.1.10.0170.00313.90
7.1.00.0200.00314.02

preferences:
64.44 ms | 400 KiB | 5 Q