3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'This is a text with multiple anchor tags. This is the first one: <a href="https://www.link1.com/" title="Link 1">Link 1</a> and this one the second: <a href="https://www.link2.com/" title="Link 2">Link 2</a> after that a lot of other text. And here the 3rd one: <a href="https://www.link3.com/" title="Link 3">Link 3</a> Some other text.'; $dom = new DOMDocument(); // since you have a fragment, wrap it in a <body> $dom->loadHTML("<body>".$str."</body>"); $links = $dom->getElementsByTagName("a"); while($link = $links[0]) { $link->parentNode->insertBefore(new DOMText($link->getAttribute("href")),$link); $link->parentNode->removeChild($link); } $result = $dom->saveHTML($dom->getElementsByTagName("body")[0]); // remove <body>..</body> wrapper $output = substr($result, strlen("<body>"), -strlen("</body>")); echo $output;

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.70.0140.00717.00
8.3.60.0130.00718.68
8.3.50.0120.00316.63
8.3.40.0110.00718.86
8.3.30.0090.00619.09
8.3.20.0050.00319.00
8.3.10.0040.00421.88
8.3.00.0070.00022.16
8.2.190.0110.01118.62
8.2.180.0070.01125.92
8.2.170.0100.00719.38
8.2.160.0200.00618.96
8.2.150.0030.00724.18
8.2.140.0080.00024.66
8.2.130.0040.00421.36
8.2.120.0080.00026.35
8.2.110.0050.00520.61
8.2.100.0140.00018.16
8.2.90.0000.00818.00
8.2.80.0000.00818.30
8.2.70.0080.00018.18
8.2.60.0050.00218.47
8.2.50.0050.00318.10
8.2.40.0040.00419.78
8.2.30.0000.00719.66
8.2.20.0050.00218.41
8.2.10.0000.00718.51
8.2.00.0000.00918.04
8.1.280.0090.00625.92
8.1.270.0000.00820.45
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0040.00424.09
8.1.230.0000.01220.52
8.1.220.0040.00418.04
8.1.210.0060.00318.77
8.1.200.0030.00517.60
8.1.190.0080.00017.55
8.1.180.0040.00519.02
8.1.170.0050.00318.64
8.1.160.0000.00719.18
8.1.150.0040.00419.11
8.1.140.0040.00420.57
8.1.130.0000.00820.42
8.1.120.0000.01117.74
8.1.110.0040.00417.66
8.1.100.0030.00517.64
8.1.90.0050.00617.70
8.1.80.0070.00717.68
8.1.70.0040.00717.66
8.1.60.0030.00917.79
8.1.50.0070.00617.75
8.1.40.0120.00317.77
8.1.30.0100.00517.87
8.1.20.0100.00517.86
8.1.10.0090.00617.79
8.1.00.0130.00217.72
8.0.300.0070.00019.79
8.0.290.0070.00317.00
8.0.280.0030.00318.65
8.0.270.0000.00717.02
8.0.260.0050.00520.48
8.0.250.0000.00817.16
8.0.240.0000.00817.11
8.0.230.0000.00717.25
8.0.220.0090.00417.07
8.0.210.0070.00617.08
8.0.200.0080.00517.17
8.0.190.0090.00517.18
8.0.180.0070.00617.10
8.0.170.0050.00817.13
8.0.160.0050.00817.15
8.0.150.0070.00517.05
8.0.140.0080.00517.02
8.0.130.0070.00615.89
8.0.120.0090.00417.09
8.0.110.0070.00517.07
8.0.100.0060.00717.01
8.0.90.0080.00516.94
8.0.80.0090.00817.08
8.0.70.0110.00117.07
8.0.60.0060.00717.00
8.0.50.0080.00417.03
8.0.30.0100.00717.24
8.0.20.0080.00917.25
8.0.10.0060.00717.14
8.0.00.0080.00717.05
7.4.330.0000.00515.55
7.4.320.0000.00616.78
7.4.300.0090.00516.77
7.4.290.0070.00516.70
7.4.280.0100.00316.65
7.4.270.0090.00316.75
7.4.260.0070.00516.71
7.4.250.0070.00516.70
7.4.240.0080.00516.65
7.4.230.0050.00716.62
7.4.220.0070.00516.60
7.4.210.0090.00616.74
7.4.200.0080.00416.79
7.4.190.0120.00316.83
7.4.180.0100.00416.76
7.4.160.0110.00416.52
7.4.150.0060.00416.51
7.4.140.0120.00717.51
7.4.130.0110.00616.68
7.4.120.0070.01016.68
7.4.110.0140.00416.62
7.4.100.0050.01016.75
7.4.90.0070.00716.67
7.4.80.0080.00417.43
7.4.70.0100.00416.56
7.4.60.0090.00516.72
7.4.50.0050.00716.63
7.4.40.0080.00616.56
7.4.30.0040.00716.45
7.4.20.0070.00616.69
7.4.10.0020.00916.54
7.4.00.0080.00516.45
7.3.330.0110.00115.43
7.3.320.0070.00415.49
7.3.310.0050.00716.55
7.3.300.0080.00416.54
7.3.290.0120.00016.52
7.3.280.0100.00516.52
7.3.270.0130.00216.54
7.3.260.0130.00716.52
7.3.250.0080.00716.60
7.3.240.0080.00916.63
7.3.230.0080.00816.61
7.3.220.0110.00316.45
7.3.210.0130.00316.51
7.3.200.0080.00716.48
7.3.190.0060.00916.53
7.3.180.0070.00916.46
7.3.170.0090.00816.51
7.3.160.0090.00616.46
7.3.150.0110.00316.40
7.3.140.0120.00316.50
7.3.130.0100.00616.42
7.3.120.0130.00315.93
7.3.110.0110.00615.95
7.3.100.0100.00515.99
7.3.90.0070.00716.19
7.3.80.0080.00515.89
7.3.70.0100.00416.01
7.3.60.0090.00616.13
7.3.50.0090.00516.02
7.3.40.0070.00716.06
7.3.30.0050.00916.11
7.3.20.0060.00617.92
7.3.10.0080.00817.91
7.3.00.0100.00617.81
7.2.340.0070.00716.49
7.2.330.0080.00716.71
7.2.320.0110.00416.75
7.2.310.0100.00716.67
7.2.300.0090.00616.77
7.2.290.0100.00516.68
7.2.280.0070.00816.45
7.2.270.0080.00616.53
7.2.260.0070.00716.57
7.2.250.0120.00216.56
7.2.240.0060.01016.11
7.2.230.0110.00516.09
7.2.220.0080.00716.14
7.2.210.0080.00416.02
7.2.200.0100.00816.20
7.2.190.0080.00516.19
7.2.180.0100.00416.18
7.2.170.0110.00316.15
7.2.160.0060.00716.15
7.2.150.0070.00618.04
7.2.140.0070.00818.05
7.2.130.0130.00418.16
7.2.120.0070.00818.16
7.2.110.1340.00617.29
7.2.100.1240.00517.33
7.2.90.1290.00417.17
7.2.80.1250.00417.24
7.2.70.1560.00617.34
7.2.60.2070.00617.25
7.2.50.1130.00817.35
7.2.40.0960.00417.20
7.2.30.0760.00817.31
7.2.20.0930.00717.35
7.2.10.0070.00817.26
7.2.00.0120.00817.34
7.1.330.0130.00517.04
7.1.320.0090.00517.02
7.1.310.0100.00717.01
7.1.300.0060.00716.97
7.1.290.0090.00517.00
7.1.280.0100.00317.05
7.1.270.0100.00516.90
7.1.260.0100.00716.91
7.1.250.0080.00616.97
7.1.240.0110.00317.52
7.1.230.1330.00516.38
7.1.220.1330.00716.46
7.1.210.1450.00716.37
7.1.200.1590.00516.23
7.1.190.1550.00616.33
7.1.180.1760.00416.39
7.1.170.1670.00416.35
7.1.160.1770.00616.35
7.1.150.1350.00816.34
7.1.140.0130.00216.18
7.1.130.0180.00416.21
7.1.120.0120.00716.20
7.1.110.0160.00316.27
7.1.100.0110.00416.14
7.1.90.1470.00916.35
7.1.80.1640.00616.36
7.1.70.1710.00416.23
7.1.60.1800.00422.37
7.1.50.2800.00622.36
7.1.40.2820.00522.44
7.1.30.2260.00322.30
7.1.20.1830.00522.42
7.1.10.1540.00916.32
7.1.00.1130.00316.32
7.0.330.0130.00417.31
7.0.320.0070.00617.18
7.0.310.0130.00317.27
7.0.300.0120.00117.20
7.0.290.0080.00717.29
7.0.280.0080.00517.19
7.0.270.0090.00517.25
7.0.260.0120.00217.23
7.0.250.0100.00417.39
7.0.240.0120.00117.39
7.0.230.0130.00017.42
7.0.220.0040.00917.19
7.0.210.0090.00717.31
7.0.200.0120.00117.25
7.0.190.0080.00517.33
7.0.180.0120.00217.28
7.0.170.0110.00217.32
7.0.160.0140.00517.25
7.0.150.0120.00117.23
7.0.140.0140.00017.23
7.0.130.0110.00517.18
7.0.120.0110.00317.31
7.0.110.0130.00317.27
7.0.100.0110.00217.17
7.0.90.0110.00317.16
7.0.80.0080.00617.15
7.0.70.0090.00617.16
7.0.60.0090.00417.13
7.0.50.0100.00417.16
7.0.40.0100.00317.26
7.0.30.0090.00417.19
7.0.20.0070.00717.19
7.0.10.0120.00117.32
7.0.00.0090.00317.28
5.6.400.0090.00016.12
5.6.390.0080.00616.21
5.6.380.0100.00415.54
5.6.370.0090.00516.01
5.6.360.0040.01016.21
5.6.350.0100.00416.10
5.6.340.0080.00616.05
5.6.330.0120.00216.15
5.6.320.0090.00416.04
5.6.310.0050.00716.13
5.6.300.0080.00616.05
5.6.290.0070.00616.07
5.6.280.0130.00016.16
5.6.270.0100.00316.13
5.6.260.0060.00716.10
5.6.250.0090.00516.13
5.6.240.0070.00616.09
5.6.230.0090.00416.26
5.6.220.0090.00416.21
5.6.210.0110.00316.14
5.6.200.0100.00316.30
5.6.190.0130.00016.27
5.6.180.0080.00516.17
5.6.170.0070.00516.14
5.6.160.0130.00016.28
5.6.150.0120.00216.26
5.6.140.0040.00916.12
5.6.130.0030.01016.16
5.6.120.0130.00016.19
5.6.110.0080.00516.13
5.6.100.0110.00316.15
5.6.90.0080.00516.16
5.6.80.0000.01316.06
5.6.70.0060.00616.22
5.6.60.0090.00416.23
5.6.50.0080.00516.05
5.6.40.0050.00816.16
5.6.30.0080.00516.05
5.6.20.0050.00816.09
5.6.10.0090.00415.84
5.6.00.0090.00315.96

preferences:
28.06 ms | 401 KiB | 5 Q