3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hrefPattern = '/<a\\s+[^>]*href=(["\']??)([^"\'>]*?)\\1([^>]*)>(.*)<\/a>/siU'; $html = <<<HTML <p>If you find any cases where this code falls down, let us know using the Feedback link below.</p> <p>Before using this or similar scripts to fetch pages from other websites, we suggest you read through the related article on <a href="/php/parse-robots/">setting a user agent and parsing robots.txt</a>.</p> <h2>First checking robots.txt</h2> <p>As mentioned above, before using a script to download files you should always <a href="/php/parse-robots/">check the robots.txt file</a>. Here we're making use of the <tt>robots_allowed</tt> function from the article linked above to determine whether we're allowed to access files:</p> <code class="final">&lt;?PHP <i>// Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header.</i> <span> ini_set('user_agent', '<i>NameOfAgent (http://www.example.net)</i>');</span> $url = &quot;http://www.example.net/somepage.html&quot;; <span> if(robots_allowed($url, &quot;<i>NameOfAgent</i>&quot;)) {</span> $input = @file_get_contents($url) or die(&quot;Could not access file: $url&quot;); $regexp = &quot;<tt>&lt;a\s[^&gt;]*href=(\&quot;??)([^\&quot; &gt;]*?)\\1[^&gt;]*&gt;(.*)&lt;\/a&gt;</tt>&quot;; if(preg_match_all(&quot;/$regexp/siU&quot;, $input, $matches, PREG_SET_ORDER)) { foreach($matches as $match) { <i>// $match[2] = link address // $match[3] = link text</i> } } <span> } else { die('Access denied by robots.txt'); }</span> ?&gt;</code> HTML; preg_match_all($hrefPattern, $html, $matches); var_dump($matches);

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.0150.00317.00
8.3.50.0120.01122.18
8.3.40.0100.00719.06
8.3.30.0110.00719.22
8.3.20.0040.00420.36
8.3.10.0030.00523.66
8.3.00.0040.00420.80
8.2.180.0160.00616.63
8.2.170.0110.00722.96
8.2.160.0180.00320.38
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00419.89
8.2.110.0000.00922.31
8.2.100.0120.00018.03
8.2.90.0090.00019.34
8.2.80.0030.00517.97
8.2.70.0050.00518.00
8.2.60.0080.00417.93
8.2.50.0060.00318.07
8.2.40.0090.00020.03
8.2.30.0000.00718.43
8.2.20.0030.00618.15
8.2.10.0000.00818.26
8.2.00.0040.00418.00
8.1.280.0070.01025.92
8.1.270.0030.00623.85
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0090.00024.01
8.1.230.0090.00319.21
8.1.220.0080.00017.91
8.1.210.0030.00618.77
8.1.200.0100.00017.60
8.1.190.0050.00517.48
8.1.180.0000.01018.10
8.1.170.0080.00018.88
8.1.160.0070.00022.00
8.1.150.0090.00018.84
8.1.140.0040.00417.65
8.1.130.0030.00317.82
8.1.120.0050.00217.53
8.1.110.0000.01017.53
8.1.100.0060.00317.51
8.1.90.0050.00317.65
8.1.80.0040.00417.48
8.1.70.0070.00017.58
8.1.60.0030.00617.63
8.1.50.0000.00817.69
8.1.40.0000.00917.71
8.1.30.0060.00317.78
8.1.20.0030.00517.72
8.1.10.0050.00217.64
8.1.00.0040.00417.60
8.0.300.0050.00318.77
8.0.290.0000.00717.16
8.0.280.0000.00718.57
8.0.270.0000.00817.20
8.0.260.0070.00017.25
8.0.250.0030.00317.20
8.0.240.0040.00417.09
8.0.230.0050.00317.17
8.0.220.0030.00317.26
8.0.210.0040.00417.08
8.0.200.0030.00317.22
8.0.190.0040.00417.20
8.0.180.0040.00417.18
8.0.170.0000.00917.25
8.0.160.0000.00717.06
8.0.150.0000.00817.12
8.0.140.0040.00417.14
8.0.130.0050.00313.50
8.0.120.0030.00517.11
8.0.110.0040.00417.12
8.0.100.0050.00617.04
8.0.90.0020.00517.02
8.0.80.0120.00317.13
8.0.70.0000.00717.09
8.0.60.0000.00717.23
8.0.50.0040.00417.26
8.0.30.0060.01217.34
8.0.20.0110.00717.50
8.0.10.0000.00817.09
8.0.00.0070.01116.93
7.4.330.0030.00315.04
7.4.320.0030.00316.74
7.4.300.0000.00616.67
7.4.290.0000.00816.90
7.4.280.0080.00016.74
7.4.270.0040.00416.85
7.4.260.0030.00316.77
7.4.250.0040.00416.84
7.4.240.0040.00316.83
7.4.230.0030.00316.56
7.4.220.0150.00316.79
7.4.210.0070.00816.79
7.4.200.0040.00316.66
7.4.190.0050.00316.87
7.4.160.0110.00916.82
7.4.150.0040.01517.40
7.4.140.0090.01217.86
7.4.130.0140.00516.76
7.4.120.0090.00916.76
7.4.110.0040.01416.96
7.4.100.0120.01216.98
7.4.90.0180.00016.68
7.4.80.0090.01419.39
7.4.70.0100.00716.69
7.4.60.0150.00316.65
7.4.50.0000.00616.48
7.4.40.0120.01216.83
7.4.30.0120.00416.65
7.4.10.0070.01015.37
7.4.00.0090.00915.26
7.3.330.0040.00413.19
7.3.320.0030.00313.18
7.3.310.0040.00416.32
7.3.300.0050.00216.32
7.3.290.0130.00716.49
7.3.280.0070.01016.54
7.3.270.0090.00917.40
7.3.260.0090.00916.71
7.3.250.0100.00916.74
7.3.240.0110.00816.64
7.3.230.0080.00916.47
7.3.210.0190.00316.81
7.3.200.0090.01519.39
7.3.190.0090.00916.79
7.3.180.0040.01516.62
7.3.170.0100.00716.66
7.3.160.0080.01116.58
7.3.130.0130.00315.10
7.3.120.0050.01215.15
7.3.110.0050.01215.38
7.3.100.0110.00415.20
7.3.90.0070.00914.89
7.3.80.0050.00715.18
7.3.70.0080.00815.04
7.3.60.0090.00815.26
7.3.50.0080.00614.91
7.3.40.0070.00714.99
7.3.30.0080.01014.88
7.3.20.0070.00516.96
7.3.10.0070.00916.77
7.3.00.0030.00916.83
7.2.330.0120.00916.68
7.2.320.0150.01016.77
7.2.310.0110.01116.75
7.2.300.0070.01016.79
7.2.290.0070.01016.72
7.2.260.0090.00914.81
7.2.250.0100.00614.91
7.2.240.0090.01015.18
7.2.230.0080.01115.03
7.2.220.0050.01315.12
7.2.210.0110.00315.06
7.2.200.0060.01015.04
7.2.190.0080.00715.26
7.2.180.0080.00714.94
7.2.170.0070.00915.31
7.2.160.0120.00415.32
7.2.150.0040.01117.16
7.2.140.0000.01616.87
7.2.130.0080.00816.77
7.2.120.0110.00616.87
7.2.110.0090.00516.84
7.2.100.0080.00817.05
7.2.90.0060.00916.82
7.2.80.0040.01517.12
7.2.70.0060.01017.00
7.2.60.0020.01216.99
7.2.50.0070.01116.73
7.2.40.0120.00317.08
7.2.30.0040.01517.13
7.2.20.0060.01017.07
7.2.10.0070.00716.95
7.2.00.0000.01218.40
7.1.330.0040.01116.05
7.1.320.0070.00816.12
7.1.310.0070.00815.75
7.1.300.0080.00415.80
7.1.290.0050.01115.98
7.1.280.0070.01015.94
7.1.270.0030.01315.91
7.1.260.0050.01115.86
7.1.250.0120.00415.76
7.1.240.0030.00915.95
7.1.230.0030.01016.06
7.1.220.0030.01415.96
7.1.210.0000.01315.85
7.1.200.0030.01015.99
7.1.190.0110.00316.09
7.1.180.0000.01016.16
7.1.170.0070.01015.91
7.1.160.0050.00815.97
7.1.150.0030.01416.00
7.1.140.0000.01515.68
7.1.130.0030.01215.87
7.1.120.0030.01015.96
7.1.110.0000.01015.97
7.1.100.0040.01217.23
7.1.90.0000.01415.98
7.1.80.0030.01015.93
7.1.70.0060.00816.54
7.1.60.0140.00417.69
7.1.50.0060.00916.69
7.1.40.0060.01215.89
7.1.30.0110.00315.84
7.1.20.0070.00316.03
7.1.10.0060.00916.00
7.1.00.0050.04219.31
7.0.330.0070.00715.43
7.0.320.0040.01115.59
7.0.310.0070.00315.45
7.0.300.0030.00615.46
7.0.290.0090.00615.40
7.0.280.0030.00915.56
7.0.270.0060.00315.68
7.0.260.0030.01315.47
7.0.250.0120.00315.59
7.0.240.0060.00315.75
7.0.230.0060.00915.57
7.0.220.0030.00515.61
7.0.210.0000.01215.63
7.0.200.0090.00416.32
7.0.190.0100.00715.52
7.0.180.0090.00615.57
7.0.170.0110.00315.46
7.0.160.0110.00415.73
7.0.150.0030.01015.36
7.0.140.0060.04018.86
7.0.130.0030.00915.45
7.0.120.0100.00315.45
7.0.110.0020.02717.82
7.0.100.0080.02117.82
7.0.90.0030.02817.83
7.0.80.0170.02017.79
7.0.70.0070.02517.63
7.0.60.0070.02117.79
7.0.50.0050.04017.85
7.0.40.0040.04716.60
7.0.30.0080.03316.65
7.0.20.0110.03016.80
7.0.10.0080.03716.66
7.0.00.0030.02716.59
5.6.400.0060.01014.55
5.6.390.0040.01114.28
5.6.380.0110.00314.32
5.6.370.0040.00413.91
5.6.360.0100.00714.39
5.6.350.0000.01814.31
5.6.340.0110.00414.34
5.6.330.0070.00314.52
5.6.320.0040.01114.54
5.6.310.0060.00914.24
5.6.300.0080.00614.29
5.6.290.0030.01013.98
5.6.280.0050.03817.68
5.6.270.0090.00014.55
5.6.260.0010.03617.56
5.6.250.0090.02117.65
5.6.240.0120.01817.60
5.6.230.0050.04317.68
5.6.220.0080.02517.50
5.6.210.0070.04117.41
5.6.200.0100.04017.44
5.6.190.0100.02217.44
5.6.180.0060.04617.52
5.6.170.0030.03317.44
5.6.160.0080.02217.55
5.6.150.0090.03917.54
5.6.140.0040.02917.58
5.6.130.0020.03317.55
5.6.120.0020.02817.63
5.6.110.0050.02417.48
5.6.100.0050.02317.52
5.6.90.0030.02717.41
5.6.80.0080.02117.11
5.6.70.0000.02617.18
5.6.60.0030.02317.08
5.6.50.0090.01717.22
5.6.40.0090.01917.05
5.6.30.0030.03017.17
5.6.20.0100.01817.28
5.6.10.0070.02717.21
5.6.00.0080.03017.38
5.5.380.0070.02015.96
5.5.370.0050.02115.86
5.5.360.0070.03215.74
5.5.350.0070.03815.87
5.5.340.0060.04316.10
5.5.330.0090.04616.01
5.5.320.0090.04416.04
5.5.310.0030.04816.11
5.5.300.0080.02216.28
5.5.290.0060.03116.07
5.5.280.0030.03116.20
5.5.270.0070.02216.04
5.5.260.0060.02416.01
5.5.250.0050.02615.96
5.5.240.0040.02615.72
5.5.230.0080.01715.78
5.5.220.0050.02215.95
5.5.210.0070.01715.73
5.5.200.0070.01915.69
5.5.190.0060.01815.87
5.5.180.0030.02815.68
5.5.170.0060.00614.37
5.5.160.0030.02815.74
5.5.150.0060.02415.79
5.5.140.0070.02215.79
5.5.130.0070.02315.73
5.5.120.0060.02015.90
5.5.110.0020.02415.92
5.5.100.0090.01615.72
5.5.90.0070.01715.65
5.5.80.0100.02215.56
5.5.70.0040.02415.56
5.5.60.0050.02015.83
5.5.50.0020.02715.59
5.5.40.0030.02515.53
5.5.30.0030.02615.81
5.5.20.0060.02215.45
5.5.10.0030.02315.62
5.5.00.0070.01915.71
5.4.450.0090.02615.07
5.4.440.0100.02815.15
5.4.430.0030.02315.18
5.4.420.0060.02515.19
5.4.410.0080.02115.07
5.4.400.0000.02415.10
5.4.390.0080.01714.97
5.4.380.0070.02014.84
5.4.370.0040.01815.01
5.4.360.0100.01514.69
5.4.350.0050.01814.99
5.4.340.0060.01814.91
5.4.330.0050.00510.88
5.4.320.0030.02515.04
5.4.310.0030.03114.89
5.4.300.0050.02114.83
5.4.290.0060.02114.82
5.4.280.0020.02514.97
5.4.270.0050.02214.91
5.4.260.0060.01914.83
5.4.250.0070.02115.08
5.4.240.0070.01714.87
5.4.230.0030.02015.02
5.4.220.0050.02214.93
5.4.210.0040.02514.94
5.4.200.0070.02214.94
5.4.190.0060.02014.98
5.4.180.0080.01814.84
5.4.170.0070.02214.88
5.4.160.0010.02114.98
5.4.150.0090.01514.92
5.4.140.0070.02013.73
5.4.130.0080.01713.59
5.4.120.0060.01713.51
5.4.110.0030.02213.78
5.4.100.0040.02413.66
5.4.90.0070.01713.56
5.4.80.0030.02013.38
5.4.70.0070.03613.61
5.4.60.0060.03413.64
5.4.50.0020.02313.62
5.4.40.0070.03613.51
5.4.30.0030.03613.74
5.4.20.0050.03813.47
5.4.10.0070.03413.53
5.4.00.0040.02513.37
5.3.290.0030.02312.64
5.3.280.0030.02312.44
5.3.270.0020.02112.63
5.3.260.0050.02312.61
5.3.250.0050.02112.38
5.3.240.0080.01712.48
5.3.230.0070.02012.58
5.3.220.0100.02012.39
5.3.210.0050.02112.47
5.3.200.0050.01812.54
5.3.190.0020.02812.55
5.3.180.0020.02512.55
5.3.170.0060.02012.51
5.3.160.0050.04212.58
5.3.150.0070.03912.59
5.3.140.0030.03312.45
5.3.130.0070.04012.50
5.3.120.0020.03312.60
5.3.110.0050.02012.49
5.3.100.0050.02312.05
5.3.90.0080.03312.34
5.3.80.0050.02212.21
5.3.70.0070.03712.22
5.3.60.0030.02012.14
5.3.50.0070.03712.25
5.3.40.0100.03512.14
5.3.30.0050.04012.14
5.3.20.0060.03211.94
5.3.10.0070.03711.85
5.3.00.0080.01511.87
5.2.170.0030.06311.98
5.2.160.0070.02711.98
5.2.150.0000.06311.98
5.2.140.0030.02711.98
5.2.130.0000.06311.98
5.2.120.0070.05311.98
5.2.110.0030.06311.98
5.2.100.0000.03011.98
5.2.90.0130.05011.98
5.2.80.0030.06711.98
5.2.70.0000.03011.98
5.2.60.0070.02712.00
5.2.50.0100.02312.04
5.2.40.0100.05012.04
5.2.30.0030.04012.07
5.2.20.0030.03312.09
5.2.10.0030.04012.09
5.2.00.0000.03012.09
5.1.60.0030.02312.09
5.1.50.0000.03312.09
5.1.40.0070.02712.09
5.1.30.0000.03012.09
5.1.20.0000.03012.09
5.1.10.0070.02712.09
5.1.00.0000.02712.09
5.0.50.0000.04312.09
5.0.40.0000.02012.09
5.0.30.0030.03012.09
5.0.20.0000.02012.09
5.0.10.0030.03012.09
5.0.00.0030.03012.09
4.4.90.0000.04011.98
4.4.80.0030.01712.00
4.4.70.0000.01712.09
4.4.60.0030.01312.09
4.4.50.0030.01312.09
4.4.40.0030.02312.09
4.4.30.0000.01712.09
4.4.20.0000.03012.09
4.4.10.0030.01312.09
4.4.00.0000.04012.09
4.3.110.0030.01712.09
4.3.100.0030.01312.09
4.3.90.0030.01312.09
4.3.80.0000.02712.09
4.3.70.0030.01012.09
4.3.60.0000.01712.09
4.3.50.0000.01712.09
4.3.40.0030.02312.09
4.3.30.0000.01712.09
4.3.20.0000.02012.09
4.3.10.0000.01312.09
4.3.00.0030.01312.09

preferences:
40.41 ms | 401 KiB | 5 Q