3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = '/(?:src|href)\=(?:\\\'|")([^\\\'"]+)(?:\\\'|")/'; $source = <<<SRC <a href="http://www.sape.ru">some text</a> <img src='logo.jpg' alt=''></a> <img src='../../logo.jpg' alt=''></a> <img src='/path/to/file' alt=''></a> SRC; $baseUrl = 'www.sape.ru'; $callback = function($matches) use ($baseUrl) { $srcTag = $matches[0]; $url = $matches[1]; $search = array( $baseUrl, 'http://' . $baseUrl, 'https://' . $baseUrl, 'http://', 'https://', '../', './', '//', '/' ); $baseUrlReplace = 'http://' . $baseUrl . '/'; $resultUrl = $url; $count = 0; foreach($search as $s) { $count = 0; $resultUrl = preg_replace('/^' . preg_quote($s, '/') . '/', $baseUrlReplace, $url, 1, $count); if ($count == 1) { break; } } if (!$count) { $resultUrl = $baseUrlReplace . $url; } $search = array( '../', './' ); $resultUrl = preg_replace($search, '/', $resultUrl); var_dump($resultUrl); return str_replace($url, $resultUrl, $srcTag); $url = preg_replace('/^[^\/]\//', '/', $url); $path = parse_url($url, PHP_URL_PATH); //if (empty($path)) { // $path = '/'; //} $query = parse_url($url, PHP_URL_QUERY); if (!empty($query)) { $path.= '?' . $query; } $fragment = parse_url($url, PHP_URL_FRAGMENT); if (!empty($fragment)) { $path.= '#' . $fragment; } $resultUrl = 'http://' . $baseUrl . '/' . ltrim($path, '/'); //var_dump($resultUrl); return str_replace($url, $resultUrl, $srcTag); }; $source = preg_replace_callback($pattern, $callback, $source); var_dump($source);

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.0080.00816.99
8.3.50.0170.00522.24
8.3.40.0060.00919.09
8.3.30.0120.00319.21
8.3.20.0000.00720.35
8.3.10.0040.00423.65
8.3.00.0000.00819.63
8.2.180.0090.00618.36
8.2.170.0090.00622.96
8.2.160.0000.01420.64
8.2.150.0000.00924.18
8.2.140.0040.00424.66
8.2.130.0070.00726.16
8.2.120.0030.00522.21
8.2.110.0030.00622.37
8.2.100.0000.01218.28
8.2.90.0050.00319.42
8.2.80.0030.00518.18
8.2.70.0050.00518.13
8.2.60.0030.00618.29
8.2.50.0000.00918.13
8.2.40.0040.00418.47
8.2.30.0040.00718.31
8.2.20.0000.00817.90
8.2.10.0070.00318.30
8.2.00.0050.00518.02
8.1.280.0000.01825.92
8.1.270.0060.00322.27
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00623.63
8.1.230.0040.00719.22
8.1.220.0000.00817.91
8.1.210.0050.00318.77
8.1.200.0040.00417.63
8.1.190.0040.00417.52
8.1.180.0050.00318.10
8.1.170.0040.00418.91
8.1.160.0040.00422.11
8.1.150.0020.00518.82
8.1.140.0040.00417.57
8.1.130.0000.00717.90
8.1.120.0070.00017.72
8.1.110.0030.00517.55
8.1.100.0000.00717.74
8.1.90.0040.00417.55
8.1.80.0000.00817.74
8.1.70.0000.00717.66
8.1.60.0040.00417.83
8.1.50.0090.00017.68
8.1.40.0090.00017.71
8.1.30.0000.00817.75
8.1.20.0040.00417.69
8.1.10.0030.00617.78
8.1.00.0080.00017.55
8.0.300.0000.00718.77
8.0.290.0040.00417.30
8.0.280.0000.00718.45
8.0.270.0070.00017.43
8.0.260.0030.00317.05
8.0.250.0030.00317.24
8.0.240.0040.00417.16
8.0.230.0070.00017.21
8.0.220.0030.00317.14
8.0.210.0000.00917.04
8.0.200.0000.00717.18
8.0.190.0000.00817.21
8.0.180.0000.00817.14
8.0.170.0080.00017.20
8.0.160.0050.00317.10
8.0.150.0040.00417.10
8.0.140.0040.00417.00
8.0.130.0060.00013.63
8.0.120.0090.00017.16
8.0.110.0040.00417.23
8.0.100.0030.00517.02
8.0.90.0080.00017.05
8.0.80.0040.01217.08
8.0.70.0040.00417.05
8.0.60.0040.00417.04
8.0.50.0000.00816.95
8.0.30.0130.00717.31
8.0.20.0090.01117.53
8.0.10.0050.00217.14
8.0.00.0150.00317.25
7.4.330.0000.00515.00
7.4.320.0000.00616.79
7.4.300.0040.00416.86
7.4.290.0000.00716.77
7.4.280.0050.00516.78
7.4.270.0000.00716.87
7.4.260.0000.00716.83
7.4.250.0040.00416.81
7.4.240.0050.00216.80
7.4.230.0030.00516.98
7.4.220.0060.01316.80
7.4.210.0070.00916.89
7.4.200.0030.00516.97
7.4.190.0050.00216.94
7.4.160.0000.01716.89
7.4.150.0160.00317.40
7.4.140.0210.02317.86
7.4.130.0100.00716.73
7.4.120.0080.01116.81
7.4.110.0100.00716.83
7.4.100.0100.01316.73
7.4.90.0160.00316.81
7.4.80.0170.00319.39
7.4.70.0050.01116.86
7.4.60.0140.00316.65
7.4.50.0030.00616.77
7.4.40.0070.00722.77
7.4.30.0080.00916.90
7.4.10.0160.00315.13
7.4.00.0100.00715.03
7.3.330.0000.00513.67
7.3.320.0000.00613.63
7.3.310.0040.00316.63
7.3.300.0070.00016.48
7.3.290.0100.00716.55
7.3.280.0120.00916.60
7.3.270.0060.01217.40
7.3.260.0060.01316.81
7.3.250.0140.00516.59
7.3.240.0140.00416.75
7.3.230.0070.01016.78
7.3.210.0060.01116.78
7.3.200.0150.00919.39
7.3.190.0100.01016.50
7.3.180.0080.00816.80
7.3.170.0100.01016.66
7.3.160.0050.01116.57
7.3.130.0100.00715.16
7.3.120.0030.01614.88
7.3.110.0100.01015.12
7.3.100.0070.00715.43
7.3.90.0030.01215.09
7.3.80.0040.01115.12
7.3.70.0140.00415.16
7.3.60.0000.01115.14
7.3.50.0060.00315.15
7.3.40.0030.01015.14
7.3.30.0070.01014.76
7.3.20.0100.00716.79
7.3.10.0030.00716.95
7.3.00.0080.00516.89
7.2.330.0130.01016.99
7.2.320.0150.00316.96
7.2.310.0090.00916.88
7.2.300.0070.01016.92
7.2.290.0110.00716.90
7.2.260.0040.01915.33
7.2.250.0070.00414.96
7.2.240.0100.00615.42
7.2.230.0030.01015.34
7.2.220.0030.01015.45
7.2.210.0100.00315.25
7.2.200.0100.00315.39
7.2.190.0080.00415.29
7.2.180.0060.00615.28
7.2.170.0070.01015.32
7.2.160.0040.01115.44
7.2.150.0030.01217.15
7.2.140.0030.01017.24
7.2.130.0070.00917.08
7.2.120.0050.01017.20
7.2.110.0070.00717.17
7.2.100.0060.00717.16
7.2.90.0080.00517.21
7.2.80.0040.00917.17
7.2.70.0050.00917.02
7.2.60.0040.00917.12
7.2.50.0040.00917.15
7.2.40.0040.00817.02
7.2.30.0070.00917.11
7.2.20.0010.01117.05
7.2.10.0050.00817.17
7.2.00.0080.00717.22
7.1.330.0030.01216.22
7.1.320.0130.00316.24
7.1.310.0040.01116.11
7.1.300.0080.00515.68
7.1.290.0030.01016.15
7.1.280.0040.01115.70
7.1.270.0070.00716.03
7.1.260.0100.00015.93
7.1.250.0070.00715.88
7.1.240.0000.01316.01
7.1.230.0030.01216.18
7.1.220.0030.00615.75
7.1.210.0030.01315.69
7.1.200.0040.01015.97
7.1.190.0000.01216.06
7.1.180.0040.01116.03
7.1.170.0030.00716.07
7.1.160.0000.01015.77
7.1.150.0060.01215.98
7.1.140.0000.01216.07
7.1.130.0030.01315.67
7.1.120.0070.00716.14
7.1.110.0060.00816.18
7.1.100.0070.00715.99
7.1.90.0000.01015.83
7.1.80.0100.00315.95
7.1.70.0040.00716.82
7.1.60.0120.00717.68
7.1.50.0100.00916.62
7.1.40.0080.00615.90
7.1.30.0040.00715.82
7.1.20.0060.00615.94
7.1.10.0040.01115.91
7.1.00.0100.03519.18
7.0.330.0060.00915.65
7.0.320.0090.00615.54
7.0.310.0070.00715.65
7.0.300.0100.00615.39
7.0.290.0100.00715.71
7.0.280.0130.00715.50
7.0.270.0040.01115.66
7.0.260.0000.01515.84
7.0.250.0090.00615.36
7.0.240.0060.00615.73
7.0.230.0060.00815.62
7.0.220.0040.01115.43
7.0.210.0060.00615.77
7.0.200.0050.00916.30
7.0.190.0080.00815.78
7.0.180.0070.00715.31
7.0.170.0000.01415.57
7.0.160.0160.00015.70
7.0.150.0060.00915.58
7.0.140.0060.03918.92
7.0.130.0000.01715.61
7.0.120.0100.00715.46
7.0.110.0090.00915.39
7.0.100.0040.01115.62
7.0.90.0070.01015.75
7.0.80.0000.01515.72
7.0.70.0030.01215.60
7.0.60.0060.04717.76
7.0.50.0080.02316.76
7.0.40.0130.03316.86
7.0.30.0280.04216.87
7.0.20.0190.02716.86
7.0.10.0090.02216.95
7.0.00.0100.03816.78
5.6.400.0040.01214.58
5.6.390.0070.01314.74
5.6.380.0130.00614.59
5.6.370.0090.00414.25
5.6.360.0000.01214.36
5.6.350.0070.01014.46
5.6.340.0100.01014.54
5.6.330.0030.01214.26
5.6.320.0070.01014.76
5.6.310.0090.00414.68
5.6.300.0080.00814.11
5.6.290.0070.01314.55
5.6.280.0030.04217.82
5.6.270.0160.00314.59
5.6.260.0040.01414.60
5.6.250.0070.00714.62
5.6.240.0100.00614.66
5.6.230.0030.01414.71
5.6.220.0120.00314.38
5.6.210.0020.03017.65
5.6.200.0050.04616.51
5.6.190.0100.04717.54
5.6.180.0070.03117.50
5.6.170.0100.02917.55
5.6.160.0050.04517.51
5.6.150.0090.04116.40
5.6.140.0100.03916.50
5.6.130.0090.03016.43
5.6.120.0090.04617.96
5.6.110.0080.04817.67
5.6.100.0100.04317.76
5.6.90.0090.03717.84
5.6.80.0100.04317.39
5.6.70.2230.02317.47
5.6.60.0090.00914.30
5.6.50.0090.00914.36
5.6.40.0070.01014.51
5.6.30.0070.00714.31
5.6.20.0030.01014.34
5.6.10.0070.00414.41
5.6.00.0030.00914.27
5.5.380.0080.00814.35
5.5.370.0080.00414.49
5.5.360.0000.01414.40
5.5.350.0060.04317.55
5.5.340.0050.03116.19
5.5.330.0050.04117.51
5.5.320.0170.02517.26
5.5.310.0210.02817.21
5.5.300.0070.04016.07
5.5.290.0080.04316.23
5.5.280.0100.02017.55
5.5.270.0020.02717.49
5.5.260.0070.02317.65
5.5.250.0090.04017.55
5.5.240.0160.03117.31
5.5.230.0000.01614.43
5.5.220.0030.01414.34
5.5.210.0030.01314.17
5.5.200.0030.01414.50
5.5.190.0050.00914.38
5.5.180.0070.00714.47
5.5.170.0040.00814.32
5.5.160.0050.00914.28
5.5.150.0080.00314.24
5.5.140.0080.00814.55
5.5.130.0000.00814.19
5.5.120.0070.00714.53
5.5.110.0120.00414.13
5.5.100.0130.00014.44
5.5.90.0050.00514.30
5.5.80.0030.01014.12
5.5.70.0100.00714.18
5.5.60.0040.01114.13
5.5.50.0120.00314.32
5.5.40.0000.01214.58
5.5.30.0130.00014.61
5.5.20.0060.00613.98
5.5.10.0000.00914.09
5.5.00.0090.00614.33
5.4.450.0120.02715.60
5.4.440.0100.03815.54
5.4.430.0150.02915.48
5.4.420.0130.03815.47
5.4.410.0190.03815.49
5.4.400.0180.03915.45
5.4.390.0170.03715.44
5.4.380.0150.02715.35
5.4.370.0130.02315.43
5.4.360.0130.02315.40
5.4.350.0120.02915.48
5.4.340.0180.02015.31
5.4.330.0000.00911.64
5.4.320.0150.02615.45
5.4.310.0180.03315.37
5.4.300.0200.03715.35
5.4.290.0150.03315.42
5.4.280.0170.02315.43
5.4.270.0170.02915.40
5.4.260.0200.03215.41
5.4.250.0270.02815.39
5.4.240.0180.03615.25
5.4.230.0180.04015.26
5.4.220.0170.03815.36
5.4.210.0140.02415.43
5.4.200.0150.03115.31
5.4.190.0120.04515.42
5.4.180.0130.04015.43
5.4.170.0130.02515.38
5.4.160.0120.03915.36
5.4.150.0130.02715.36
5.4.140.0170.03814.02
5.4.130.0170.03714.09
5.4.120.0180.03614.10
5.4.110.0240.03314.16
5.4.100.0200.03114.10
5.4.90.0130.02914.12
5.4.80.0140.02213.93
5.4.70.0130.03613.98
5.4.60.0200.03414.04
5.4.50.0170.03514.04
5.4.40.0180.03814.11
5.4.30.0120.03313.98
5.4.20.0200.01313.95
5.4.10.0180.04014.08
5.4.00.0160.03013.79
5.3.290.0160.03113.22
5.3.280.0150.04013.09
5.3.270.0150.04113.17
5.3.260.0140.03113.21
5.3.250.0140.02513.16
5.3.240.0150.03713.13
5.3.230.0170.03913.10
5.3.220.0150.02913.12
5.3.210.0170.02813.15
5.3.200.0130.03813.12
5.3.190.0160.02813.16
5.3.180.0140.02213.20
5.3.170.0130.02513.11
5.3.160.0160.02513.07
5.3.150.0180.03713.12
5.3.140.0160.03413.10
5.3.130.0180.04013.10
5.3.120.0100.03013.09
5.3.110.0190.03713.11
5.3.100.0260.03112.80
5.3.90.0160.02612.83
5.3.80.0170.03512.85
5.3.70.0190.03412.90
5.3.60.0170.02212.87
5.3.50.0220.03212.77
5.3.40.0170.03712.87
5.3.30.0200.03312.90
5.3.20.0150.02712.67
5.3.10.0160.02812.61
5.3.00.0170.02412.71
5.2.170.0270.06012.21
5.2.160.0270.03312.21
5.2.150.0230.05712.21
5.2.140.0170.04712.21
5.2.130.0170.03012.21
5.2.120.0230.05712.21
5.2.110.0330.04712.21
5.2.100.0130.03712.21
5.2.90.0170.03012.21
5.2.80.0270.03012.21
5.2.70.0300.05012.21
5.2.60.0230.04312.21
5.2.50.0270.03312.21
5.2.40.0200.03012.21
5.2.30.0170.03312.21
5.2.20.0200.05712.21
5.2.10.0130.06712.21
5.2.00.0200.05312.21
5.1.60.0170.05012.21
5.1.50.0170.03712.21
5.1.40.0230.04712.21
5.1.30.0230.05012.21
5.1.20.0130.04012.21
5.1.10.0270.02312.21
5.1.00.0170.03312.21
5.0.50.0070.02312.21
5.0.40.0030.02312.21
5.0.30.0100.02712.21
5.0.20.0100.01712.21
5.0.10.0070.02012.21
5.0.00.0100.02712.21
4.4.90.0100.02712.21
4.4.80.0070.02312.21
4.4.70.0100.03312.21
4.4.60.0170.02312.21
4.4.50.0070.03712.21
4.4.40.0070.04312.21
4.4.30.0100.03312.21
4.4.20.0100.03012.21
4.4.10.0070.01312.21
4.4.00.0070.02712.21
4.3.110.0030.01712.21
4.3.100.0100.01312.21
4.3.90.0030.01712.21
4.3.80.0100.02312.21
4.3.70.0070.01312.21
4.3.60.0070.01712.21
4.3.50.0100.01312.21
4.3.40.0070.02312.21
4.3.30.0070.01312.21
4.3.20.0030.01712.21
4.3.10.0000.01712.21
4.3.00.0030.02712.21

preferences:
36.99 ms | 401 KiB | 5 Q