3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rewrite_relative_links($md, $page, $baselink = null) { if(!$baselink) $baselink = $page->getEntity()->getRelativeLink(); $re = '/ ([^\!]?) # exclude image format \[ (.*?) # link title (non greedy) \] \( (.*?) # link url (non greedy) \) /x'; preg_match_all($re, $md, $matches); // relative path (relative to module base folder), without the filename. // For "sapphire/en/current/topics/templates", this would be "templates" $relativePath = dirname($page->getRelativePath()); if($relativePath == '.') $relativePath = ''; // file base link $fileBaseLink = Director::makeRelative(dirname($page->getPath())); if($matches) { foreach($matches[0] as $i => $match) { $title = $matches[2][$i]; $url = $matches[3][$i]; // Don't process API links if(preg_match('/^api:/', $url)) continue; // Don't process absolute links (based on protocol detection) $urlParts = parse_url($url); if($urlParts && isset($urlParts['scheme'])) continue; // for images we need to use the file base path if(preg_match('/_images/', $url)) { $relativeUrl = Controller::join_links( Director::absoluteBaseURL(), $fileBaseLink, $url ); } else { // Rewrite public URL if(preg_match('/^\//', $url)) { // Absolute: Only path to module base $relativeUrl = Controller::join_links($baselink, $url); } else { // Relative: Include path to module base and any folders $relativeUrl = Controller::join_links($baselink, $relativePath, $url); } } // Resolve relative paths while(strpos($relativeUrl, '..') !== FALSE) { $relativeUrl = preg_replace('/\w+\/\.\.\//', '', $relativeUrl); } // Replace any double slashes (apart from protocol) $relativeUrl = preg_replace('/([^:])\/{2,}/', '$1/', $relativeUrl); // Replace in original content $md = str_replace( $match, sprintf('%s[%s](%s)', $matches[1][$i], $title, $relativeUrl), $md ); } } return $md; }

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.0210.00018.31
8.3.50.0100.01021.99
8.3.40.0080.00818.76
8.3.30.0120.00318.54
8.3.20.0070.00718.50
8.3.10.0040.00420.80
8.3.00.0030.00623.61
8.2.180.0040.01216.38
8.2.170.0040.01122.96
8.2.160.0140.00320.39
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.01126.16
8.2.120.0050.00320.49
8.2.110.0090.00020.24
8.2.100.0040.00817.59
8.2.90.0040.00417.72
8.2.80.0060.00317.97
8.2.70.0030.00517.50
8.2.60.0080.00017.68
8.2.50.0000.00818.07
8.2.40.0040.00418.05
8.2.30.0000.00721.21
8.2.20.0030.00617.50
8.2.10.0000.00717.64
8.2.00.0000.00717.54
8.1.280.0070.01125.92
8.1.270.0070.00023.99
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00622.24
8.1.230.0070.00420.88
8.1.220.0090.00017.74
8.1.210.0000.00818.91
8.1.200.0000.00917.22
8.1.190.0040.00419.06
8.1.180.0060.00318.10
8.1.170.0030.00518.41
8.1.160.0000.00718.79
8.1.150.0000.00718.55
8.1.140.0060.00317.35
8.1.130.0030.00317.79
8.1.120.0040.00417.27
8.1.110.0040.00417.36
8.1.100.0000.00717.25
8.1.90.0040.00417.24
8.1.80.0030.00417.35
8.1.70.0070.00017.32
8.1.60.0070.00017.45
8.1.50.0040.00417.29
8.1.40.0000.00817.40
8.1.30.0020.00517.56
8.1.20.0030.00617.52
8.1.10.0040.00417.28
8.1.00.0000.00817.39
8.0.300.0070.00019.77
8.0.290.0040.00417.05
8.0.280.0000.00718.42
8.0.270.0000.00717.06
8.0.260.0050.00316.59
8.0.250.0040.00416.92
8.0.240.0000.00816.84
8.0.230.0030.00316.84
8.0.220.0070.00416.81
8.0.210.0000.00716.76
8.0.200.0000.00716.74
8.0.190.0000.00816.73
8.0.180.0070.00016.78
8.0.170.0080.00016.80
8.0.160.0030.00516.82
8.0.150.0040.00416.74
8.0.140.0080.00316.73
8.0.130.0060.00313.26
8.0.120.0060.00515.00
8.0.110.0060.00415.00
8.0.100.0060.00415.03
8.0.90.0060.00515.03
8.0.80.0090.00515.00
8.0.70.0050.00514.94
8.0.60.0070.00314.85
8.0.50.0070.00315.03
8.0.30.0080.00815.71
8.0.20.0070.00916.00
8.0.10.0040.00615.16
8.0.00.0070.01115.58
7.4.330.0030.00314.72
7.4.320.0030.00316.50
7.4.300.0030.00316.50
7.4.290.0000.00716.43
7.4.280.0080.00016.40
7.4.270.0030.00316.40
7.4.260.0050.00013.22
7.4.250.0020.00514.79
7.4.240.0030.00714.81
7.4.230.0080.00314.76
7.4.220.0090.01014.75
7.4.210.0070.00715.81
7.4.200.0030.00614.88
7.4.190.0050.00514.94
7.4.180.0070.00013.23
7.4.160.0060.00814.90
7.4.150.0080.00515.29
7.4.140.0090.00916.31
7.4.130.0190.00615.29
7.4.120.0090.00715.37
7.4.110.0100.00514.69
7.4.100.0100.00514.81
7.4.90.0090.00814.80
7.4.80.0100.00516.19
7.4.70.0080.01014.58
7.4.60.0070.01014.75
7.4.50.0070.00314.71
7.4.40.0010.00817.75
7.4.30.0030.00814.69
7.4.20.0000.00513.04
7.4.10.0000.00613.00
7.4.00.0020.00814.07
7.3.330.0050.00013.16
7.3.320.0030.00313.10
7.3.310.0010.00514.65
7.3.300.0030.00314.71
7.3.290.0050.00614.67
7.3.280.0090.00715.46
7.3.270.0050.00615.21
7.3.260.0090.00516.54
7.3.250.0070.00915.13
7.3.240.0040.00814.74
7.3.230.0030.00814.81
7.3.220.0030.00312.96
7.3.210.0060.00614.68
7.3.200.0050.00816.31
7.3.190.0070.00414.67
7.3.180.0050.00614.81
7.3.170.0030.00814.64
7.3.160.0040.00614.61
7.3.150.0060.00013.07
7.3.140.0030.00313.16
7.3.130.0000.00512.94
7.3.120.0000.01113.85
7.3.110.0030.00313.04
7.3.100.0050.00013.11
7.3.90.0020.00213.36
7.3.80.0050.00012.97
7.3.70.0030.00213.34
7.3.60.0000.00513.37
7.3.50.0000.00613.19
7.3.40.0070.00013.15
7.3.30.0030.00313.41
7.3.20.0040.00415.07
7.3.10.0030.00314.97
7.3.00.0000.00615.08
7.2.340.0120.00012.99
7.2.330.0160.00314.64
7.2.320.0080.00814.82
7.2.310.0110.00514.82
7.2.300.0110.00314.68
7.2.290.0080.00914.76
7.2.280.0070.00513.17
7.2.270.0130.00013.18
7.2.260.0110.00413.17
7.2.250.0080.00413.17
7.2.240.0090.00413.04
7.2.230.0100.00313.04
7.2.220.0090.00413.17
7.2.210.0140.00013.03
7.2.200.0080.00813.13
7.2.190.0110.00313.33
7.2.180.0130.00013.27
7.2.170.0100.00313.22
7.2.160.0130.00013.33
7.2.150.0080.00514.90
7.2.140.0060.00615.01
7.2.130.0090.00415.35
7.2.120.0080.00615.14
7.2.110.0140.00015.08
7.2.100.0050.00915.24
7.2.90.0140.00015.03
7.2.80.0070.00715.25
7.2.70.0090.00515.14
7.2.60.0090.00614.99
7.2.50.0070.00715.21
7.2.40.0100.00315.25
7.2.30.0110.00315.03
7.2.20.0130.00015.02
7.2.10.0120.00315.31
7.2.00.0090.00817.23
7.1.330.0060.00614.14
7.1.320.0060.00614.00
7.1.310.0080.00414.08
7.1.300.0130.00014.07
7.1.290.0120.00014.04
7.1.280.0110.00414.14
7.1.270.0120.00014.22
7.1.260.0000.01214.28
7.1.250.0100.00313.91
7.1.240.0140.00014.15
7.1.230.0120.00014.16
7.1.220.0080.00414.19
7.1.210.0060.00614.07
7.1.200.0120.00014.19
7.1.190.0080.00414.16
7.1.180.0090.00314.10
7.1.170.0060.00614.04
7.1.160.0060.00614.07
7.1.150.0080.00413.91
7.1.140.0120.00014.01
7.1.130.0090.00414.17
7.1.120.0090.00314.09
7.1.110.0050.00914.05
7.1.100.0050.00716.11
7.1.90.0090.00414.11
7.1.80.0130.00014.11
7.1.70.0070.00315.35
7.1.60.0110.00916.76
7.1.50.0050.01315.43
7.1.40.0100.00214.03
7.1.30.0060.00614.07
7.1.20.0090.00313.90
7.1.10.0070.00713.98
7.1.00.0050.03318.25
7.0.330.0080.00414.02
7.0.320.0060.00613.98
7.0.310.0120.00013.84
7.0.300.0100.00213.81
7.0.290.0090.00314.02
7.0.280.0130.00013.85
7.0.270.0040.00913.98
7.0.260.0120.00013.95
7.0.250.0100.00314.17
7.0.240.0120.00013.95
7.0.230.0120.00014.00
7.0.220.0080.00414.05
7.0.210.0120.00013.84
7.0.200.0060.00515.36
7.0.190.0060.00614.02
7.0.180.0070.00713.99
7.0.170.0080.00414.16
7.0.160.0090.00313.82
7.0.150.0110.00313.96
7.0.140.0050.04018.06
7.0.130.0090.00313.98
7.0.120.0080.00413.91
7.0.110.0080.00414.01
7.0.100.0120.00014.06
7.0.90.0070.00513.91
7.0.80.0060.00613.81
7.0.70.0030.04817.79
7.0.60.0090.03817.82
7.0.50.0020.04917.99
7.0.40.0040.04616.96
7.0.30.0080.04317.09
7.0.20.0050.04517.01
7.0.10.0130.03717.04
7.0.00.0060.04316.96
5.6.400.0090.00312.51
5.6.390.0140.00012.67
5.6.380.0090.00212.55
5.6.370.0110.00012.51
5.6.360.0130.00012.66
5.6.350.0130.00012.51
5.6.340.0000.01212.36
5.6.330.0090.00312.36
5.6.320.0100.00212.39
5.6.310.0040.00812.50
5.6.300.0110.00012.27
5.6.290.0040.00812.50
5.6.280.0050.03816.76
5.6.270.0130.00012.38
5.6.260.0080.00312.55
5.6.250.0120.00012.32
5.6.240.0120.00012.70
5.6.230.0110.00012.60
5.6.220.0090.03816.51
5.6.210.0060.03716.59
5.6.200.0060.04516.74
5.6.190.0080.03316.77
5.6.180.0080.03816.79
5.6.170.0090.03216.70
5.6.160.0110.03816.76
5.6.150.0060.04316.87
5.6.140.0080.02516.86
5.6.130.0080.03816.75
5.6.120.0060.04516.86
5.6.110.0040.04516.75
5.6.100.0070.02916.73
5.6.90.0050.04416.90
5.6.80.0040.04416.40
5.6.70.0030.04416.54
5.6.60.0020.03816.62
5.6.50.0080.04116.52
5.6.40.0040.04516.43
5.6.30.0100.03416.51
5.6.20.0060.02816.37
5.6.10.0020.03516.52
5.6.00.0050.04016.48
5.5.380.0080.00412.46
5.5.370.0050.00512.58
5.5.360.0060.04716.35
5.5.350.0130.03316.37
5.5.340.0110.03816.68
5.5.330.0070.02916.74
5.5.320.0080.04216.71
5.5.310.0070.04216.65
5.5.300.0060.04316.56
5.5.290.0050.04416.66
5.5.280.0050.04816.66
5.5.270.0050.03016.65
5.5.260.0020.03316.70
5.5.250.0100.03716.50
5.5.240.0070.03916.43
5.5.230.0050.03116.34
5.5.220.0040.04016.38
5.5.210.0080.04116.38
5.5.200.0060.03316.20
5.5.190.0060.03716.28
5.5.180.0070.03516.19
5.5.170.0060.00612.18
5.5.160.0080.04016.34
5.5.150.0110.03716.24
5.5.140.0070.04116.07
5.5.130.0080.02516.17
5.5.120.0110.03716.18
5.5.110.0060.04416.33
5.5.100.0050.03016.35
5.5.90.0080.03916.13
5.5.80.0050.03816.32
5.5.70.0030.04116.30
5.5.60.0030.03516.27
5.5.50.0050.03516.31
5.5.40.0050.04016.24
5.5.30.0090.03816.41
5.5.20.0030.03316.41
5.5.10.0060.02316.35
5.5.00.0050.03516.25
5.4.450.0020.04416.05
5.4.440.0090.03215.91
5.4.430.0020.04416.08
5.4.420.0040.04216.04
5.4.410.0060.04215.97
5.4.400.0040.04415.74
5.4.390.0080.02715.74
5.4.380.0000.04815.76
5.4.370.0040.02615.80
5.4.360.0090.03015.74
5.4.350.0040.03715.85
5.4.340.0040.04115.62
5.4.330.0130.00012.58
5.4.320.0090.03315.74
5.4.310.0070.03515.64
5.4.300.0090.03315.75
5.4.290.0020.03215.75
5.4.280.0050.03115.82
5.4.270.0030.04115.79
5.4.260.0070.03515.72
5.4.250.0050.02915.69
5.4.240.0060.03615.69
5.4.230.0060.02715.65
5.4.220.0120.02715.63
5.4.210.0000.04615.58
5.4.200.0080.01815.53
5.4.190.0060.03015.74
5.4.180.0080.02615.67
5.4.170.0150.03215.60
5.4.160.0090.02515.64
5.4.150.0130.03215.61
5.4.140.0080.02314.28
5.4.130.0040.04214.40
5.4.120.0060.03614.36
5.4.110.0070.03714.34
5.4.100.0020.03914.47
5.4.90.0070.03814.36
5.4.80.0060.03614.45
5.4.70.0080.03014.26
5.4.60.0050.03814.46
5.4.50.0060.03114.29
5.4.40.0060.03714.34
5.4.30.0060.03314.41
5.4.20.0060.03514.52
5.4.10.0060.04314.44
5.4.00.0030.04113.98
5.3.290.0070.03813.80
5.3.280.0020.04413.65
5.3.270.0030.04313.78
5.3.260.0060.03813.75
5.3.250.0030.03813.67
5.3.240.0060.03513.75
5.3.230.0110.04013.72
5.3.220.0040.03413.59
5.3.210.0080.03813.55
5.3.200.0020.04213.59
5.3.190.0050.04713.70
5.3.180.0050.03913.66
5.3.170.0050.03513.74
5.3.160.0070.02613.83
5.3.150.0060.03913.72
5.3.140.0080.03613.68
5.3.130.0050.04313.76
5.3.120.0050.04213.62
5.3.110.0080.03913.73
5.3.100.0000.03413.39
5.3.90.0030.04013.33
5.3.80.0050.04013.43
5.3.70.0040.03913.35
5.3.60.0050.03713.29
5.3.50.0060.03613.42
5.3.40.0040.03313.34
5.3.30.0090.03513.21
5.3.20.0120.03313.18
5.3.10.0050.03913.03
5.3.00.0060.03613.08
5.2.170.0050.03512.08
5.2.160.0000.03812.07
5.2.150.0050.03211.95
5.2.140.0050.03311.97
5.2.130.0030.02211.93
5.2.120.0020.02912.04
5.2.110.0060.03211.92
5.2.100.0030.03212.04
5.2.90.0030.03412.03
5.2.80.0030.02811.87
5.2.70.0050.03211.90
5.2.60.0060.03211.94
5.2.50.0070.02412.01
5.2.40.0050.03111.98
5.2.30.0070.02211.99
5.2.20.0030.02511.88
5.2.10.0050.03211.95
5.2.00.0070.02311.75
5.1.60.0030.03611.45
5.1.50.0030.01511.58
5.1.40.0040.01811.64
5.1.30.0020.01911.64
5.1.20.0050.02811.54
5.1.10.0030.02511.63
5.1.00.0070.02711.42
5.0.50.0030.02511.36
5.0.40.0050.02211.36
5.0.30.0050.03311.36
5.0.20.0020.02111.36
5.0.10.0000.02511.36
5.0.00.0040.03111.36
4.4.90.0020.01811.36
4.4.80.0020.01211.36
4.4.70.0040.01811.36
4.4.60.0000.01911.36
4.4.50.0020.01311.36
4.4.40.0040.01311.36
4.4.30.0020.01711.36
4.4.20.0020.01811.36
4.4.10.0050.01211.36
4.4.00.0040.02711.36
4.3.110.0020.01511.36
4.3.100.0030.01711.36
4.3.90.0040.01611.36
4.3.80.0020.03011.36
4.3.70.0010.01811.36
4.3.60.0030.01611.36
4.3.50.0040.01711.36
4.3.40.0030.02511.36
4.3.30.0000.01811.36
4.3.20.0000.01811.36
4.3.10.0060.01411.36
4.3.00.0050.01511.36

preferences:
60.69 ms | 401 KiB | 5 Q