3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remove_index_etc($url) { $isLastCharPattern = substr($url,-1) == "*"; if ($isLastCharPattern && preg_match('/[\?#]/',$url)) { echo 1; $url = preg_replace('/^(.*)(?:\/(?:home|default|index)\..{3,4})([\?\/#\*]+.*)?$/i', "$1$2", $url); } elseif($isLastCharPattern) { echo 2; $url = preg_replace('/^(.*)(\/(?:home|default|index)\..{3,4}\/?)(\*+)$/i', "$1$2$3", $url); } else { echo 3; $url = preg_replace('/^(.*)(?:\/(?:home|default|index)\..{3,4})([\?\/#\*]+.*)*$/i', "$1$2", $url); } return $url; } echo remove_index_etc("http://a.com/index.html") . PHP_EOL; echo remove_index_etc("http://a.com/index.html*"). PHP_EOL; echo remove_index_etc("http://a.com/*index.html*"). PHP_EOL; echo remove_index_etc("http://a.com/index.html/*"). PHP_EOL; echo remove_index_etc("http://a.com/index.html?a=1"). PHP_EOL; echo remove_index_etc("http://a.com/index.html?a=1*"). PHP_EOL; echo remove_index_etc("http://a.com/index.html?*a=1"). PHP_EOL; echo remove_index_etc("http://a.com/*"). PHP_EOL; echo remove_index_etc("http://a.com"). PHP_EOL; echo remove_index_etc("http://a.com/index.html/?a=1*"). PHP_EOL; echo remove_index_etc("http://a.com/index.html#a=1*"). PHP_EOL; echo remove_index_etc("http://a.com#index.html?a=1"). PHP_EOL; echo remove_index_etc("http://a.com#index.html?a=1*"). PHP_EOL;

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.0110.01118.55
8.3.50.0070.01516.90
8.3.40.0040.01119.09
8.3.30.0120.00618.92
8.3.20.0000.01618.85
8.3.10.0050.00320.61
8.3.00.0000.00817.75
8.2.180.0110.01116.88
8.2.170.0140.00022.96
8.2.160.0030.01222.38
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0050.00519.77
8.2.110.0070.00320.59
8.2.100.0130.00019.83
8.2.90.0040.00419.47
8.2.80.0030.00617.97
8.2.70.0060.00317.88
8.2.60.0040.00418.04
8.2.50.0030.00618.07
8.2.40.0000.00818.41
8.2.30.0070.00018.11
8.2.20.0000.00817.82
8.2.10.0030.00617.98
8.2.00.0040.00418.02
8.1.280.0090.00625.92
8.1.270.0040.00423.99
8.1.260.0030.00626.35
8.1.250.0110.00428.09
8.1.240.0060.00322.10
8.1.230.0120.00017.55
8.1.220.0080.00017.91
8.1.210.0040.00418.77
8.1.200.0030.00717.47
8.1.190.0080.00017.66
8.1.180.0030.00618.10
8.1.170.0030.00619.08
8.1.160.0030.00618.93
8.1.150.0000.00818.98
8.1.140.0040.00417.73
8.1.130.0000.00717.91
8.1.120.0040.00417.60
8.1.110.0000.00817.71
8.1.100.0000.00717.57
8.1.90.0020.00517.68
8.1.80.0000.00817.65
8.1.70.0000.00817.63
8.1.60.0000.00817.83
8.1.50.0030.00617.68
8.1.40.0050.00317.74
8.1.30.0040.00417.78
8.1.20.0030.00617.82
8.1.10.0040.00417.73
8.1.00.0040.00417.70
8.0.300.0000.00818.77
8.0.290.0080.00017.00
8.0.280.0000.00718.55
8.0.270.0040.00417.35
8.0.260.0070.00017.05
8.0.250.0060.00317.05
8.0.240.0050.00517.20
8.0.230.0030.00617.20
8.0.220.0030.00417.12
8.0.210.0000.00717.14
8.0.200.0020.00517.05
8.0.190.0070.00017.17
8.0.180.0000.00717.13
8.0.170.0050.00317.07
8.0.160.0040.00417.09
8.0.150.0030.00617.05
8.0.140.0120.00017.11
8.0.130.0030.00313.59
8.0.120.0060.00317.08
8.0.110.0080.00017.17
8.0.100.0000.00817.18
8.0.90.0080.00017.05
8.0.80.0110.01117.16
8.0.70.0040.00417.10
8.0.60.0060.00317.16
8.0.50.0000.00817.25
8.0.30.0140.01117.52
8.0.20.0110.00817.46
8.0.10.0000.00717.25
8.0.00.0100.00916.85
7.4.330.0000.00514.94
7.4.320.0030.00316.95
7.4.300.0060.00016.87
7.4.290.0040.00416.95
7.4.280.0050.00316.91
7.4.270.0030.00317.01
7.4.260.0030.00313.57
7.4.250.0080.00016.82
7.4.240.0000.00716.75
7.4.230.0040.00416.65
7.4.220.0150.00916.77
7.4.210.0090.00916.93
7.4.200.0000.00817.03
7.4.190.0030.00316.96
7.4.160.0070.01016.67
7.4.150.0160.00617.18
7.4.140.0100.01117.32
7.4.130.0070.01416.84
7.4.120.0130.00516.83
7.4.110.0110.01116.73
7.4.100.0090.00916.90
7.4.90.0090.01116.84
7.4.80.0100.00718.80
7.4.70.0060.01816.86
7.4.60.0080.01116.88
7.4.50.0070.00016.76
7.4.40.0030.00822.27
7.4.30.0130.00316.71
7.4.10.0090.01215.43
7.4.00.0050.01115.27
7.3.330.0080.00013.36
7.3.320.0070.00013.32
7.3.310.0070.00016.53
7.3.300.0000.00716.53
7.3.290.0120.00316.59
7.3.280.0100.00716.54
7.3.270.0130.00417.18
7.3.260.0100.00818.24
7.3.250.0090.01216.73
7.3.240.0120.01216.71
7.3.230.0150.00316.86
7.3.210.0120.00616.54
7.3.200.0110.00619.39
7.3.190.0080.01116.76
7.3.180.0080.00816.61
7.3.170.0190.00016.76
7.3.160.0030.01316.92
7.3.130.0150.00714.67
7.3.120.0050.01115.11
7.3.110.0090.01214.60
7.3.100.0060.00915.20
7.3.90.0100.01014.95
7.3.80.0050.00515.08
7.3.70.0120.00314.84
7.3.60.0130.00315.10
7.3.50.0030.01014.61
7.3.40.0000.01314.90
7.3.30.0160.00014.99
7.3.20.0030.00617.04
7.3.10.0070.00716.66
7.3.00.0030.00916.59
7.2.330.0120.00616.78
7.2.320.0140.01016.93
7.2.310.0090.00916.73
7.2.300.0100.00716.95
7.2.290.0060.01216.93
7.2.260.0070.01115.07
7.2.250.0130.00715.40
7.2.240.0130.00315.19
7.2.230.0030.01615.16
7.2.220.0100.00715.02
7.2.210.0000.00914.95
7.2.200.0060.00915.32
7.2.190.0000.01215.26
7.2.180.0030.01314.93
7.2.170.0140.00015.08
7.2.160.0060.00615.29
7.2.150.0060.00916.86
7.2.140.0110.00416.89
7.2.130.0130.00316.79
7.2.120.0060.00617.07
7.2.110.0000.01316.79
7.2.100.0030.01017.12
7.2.90.0040.00816.86
7.2.80.0040.01116.87
7.2.70.0060.00916.85
7.2.60.0060.01017.13
7.2.50.0030.01317.18
7.2.40.0060.00616.91
7.2.30.0100.00316.95
7.2.20.0060.01216.77
7.2.10.0000.01017.13
7.2.00.0090.00616.88
7.1.330.0120.00315.93
7.1.320.0080.00816.20
7.1.310.0120.00315.86
7.1.300.0070.00715.99
7.1.290.0040.00715.84
7.1.280.0120.00316.20
7.1.270.0030.01015.72
7.1.260.0060.00315.96
7.1.250.0000.01316.13
7.1.240.0140.00015.97
7.1.230.0120.00016.00
7.1.220.0090.00615.82
7.1.210.0000.01415.84
7.1.200.0030.00715.88
7.1.190.0040.00815.99
7.1.180.0090.00616.08
7.1.170.0140.00316.14
7.1.160.0000.01015.90
7.1.150.0060.01015.89
7.1.140.0060.01216.06
7.1.130.0100.00315.66
7.1.120.0070.00315.79
7.1.110.0100.00316.17
7.1.100.0100.00316.09
7.1.90.0060.00315.97
7.1.80.0100.00315.91
7.1.70.0030.00816.64
7.1.60.0100.01017.61
7.1.50.0050.01016.68
7.1.40.0140.00315.98
7.1.30.0030.00915.82
7.1.20.0110.00415.86
7.1.10.0150.00015.86
7.1.00.0070.04319.18
7.0.330.0060.00915.45
7.0.320.0000.01015.69
7.0.310.0070.00315.44
7.0.300.0070.01015.47
7.0.290.0060.00615.44
7.0.280.0030.00915.16
7.0.270.0070.00415.33
7.0.260.0040.01415.49
7.0.250.0030.00615.54
7.0.240.0060.01215.80
7.0.230.0070.00715.59
7.0.220.0060.00615.44
7.0.210.0060.00315.81
7.0.200.0190.00615.19
7.0.190.0110.00715.64
7.0.180.0040.01415.71
7.0.170.0030.00715.60
7.0.160.0030.00615.37
7.0.150.0100.00715.18
7.0.140.0030.04318.91
7.0.130.0030.00615.69
7.0.120.0040.01115.27
7.0.110.0000.01215.21
7.0.100.0100.00315.41
7.0.90.0070.00715.52
7.0.80.0070.00315.45
7.0.70.0030.01415.65
7.0.60.0050.04817.85
7.0.50.0040.02516.81
7.0.40.0030.03015.65
7.0.30.0020.02515.75
7.0.20.0060.02315.61
7.0.10.0030.02615.72
7.0.00.0020.02715.81
5.6.400.0030.00714.68
5.6.390.0000.01614.71
5.6.380.0110.00414.21
5.6.370.0080.00614.52
5.6.360.0060.00314.39
5.6.350.0050.00514.21
5.6.340.0000.00914.57
5.6.330.0030.00614.70
5.6.320.0030.01314.80
5.6.310.0060.01214.25
5.6.300.0110.00714.40
5.6.290.0100.00614.64
5.6.280.0070.03717.67
5.6.270.0070.01014.29
5.6.260.0120.00314.57
5.6.250.0080.00814.64
5.6.240.0070.00714.35
5.6.230.0110.00714.45
5.6.220.0060.00614.25
5.6.210.0070.04417.58
5.6.200.0060.02516.41
5.6.190.0060.02616.25
5.6.180.0090.02216.28
5.6.170.0100.02616.33
5.6.160.0050.02516.27
5.6.150.0050.02116.36
5.6.140.0050.02616.38
5.6.130.0070.03716.17
5.6.120.0020.02916.25
5.6.110.0010.03816.18
5.6.100.0100.02016.41
5.6.90.0150.03516.42
5.6.80.0080.04316.07
5.6.70.0050.04415.86
5.6.60.0130.02315.96
5.6.50.0110.03515.87
5.6.40.0020.04016.05
5.6.30.0050.02516.03
5.6.20.0070.02415.90
5.6.10.0050.03515.81
5.6.00.0010.02815.96
5.5.380.0040.00714.34
5.5.370.0030.01014.66
5.5.360.0110.00314.31
5.5.350.1870.02517.37
5.5.340.0060.02216.25
5.5.330.0020.02616.19
5.5.320.0050.02216.07
5.5.310.0110.01916.13
5.5.300.0030.03316.09
5.5.290.0030.02515.99
5.5.280.0050.04516.22
5.5.270.0000.05015.95
5.5.260.0080.02216.29
5.5.250.0080.03816.14
5.5.240.0090.03715.87
5.5.230.0020.02815.89
5.5.220.0070.04015.82
5.5.210.0030.04515.77
5.5.200.0050.03015.74
5.5.190.0060.02115.81
5.5.180.0080.04515.81
5.5.170.0060.00614.10
5.5.160.0050.03715.88
5.5.150.0100.04015.63
5.5.140.0080.04415.85
5.5.130.0050.03815.87
5.5.120.0080.04315.64
5.5.110.0080.04115.91
5.5.100.0060.04115.78
5.5.90.0080.03915.74
5.5.80.0020.02515.79
5.5.70.0080.03715.62
5.5.60.0100.04015.66
5.5.50.0030.04315.90
5.5.40.0070.02015.64
5.5.30.0080.03015.68
5.5.20.0050.02815.82
5.5.10.0130.03315.83
5.5.00.0100.03315.83
5.4.450.0000.02815.17
5.4.440.0030.04615.37
5.4.430.0050.04015.48
5.4.420.0070.04115.33
5.4.410.0140.02815.25
5.4.400.0140.03315.29
5.4.390.0080.03814.97
5.4.380.0050.04215.02
5.4.370.0100.03814.89
5.4.360.0100.04015.15
5.4.350.0020.02414.99
5.4.340.0050.02314.93
5.4.330.0040.00411.32
5.4.320.0030.04415.08
5.4.310.0120.03515.09
5.4.300.0080.04015.29
5.4.290.0020.04315.00
5.4.280.0050.03714.93
5.4.270.0060.03915.06
5.4.260.0030.03015.24
5.4.250.0000.05015.03
5.4.240.0000.02715.09
5.4.230.0110.03715.02
5.4.220.0070.03315.09
5.4.210.0050.03315.03
5.4.200.0070.02215.07
5.4.190.0050.03915.02
5.4.180.0070.03315.05
5.4.170.0070.02715.07
5.4.160.0070.03815.10
5.4.150.0120.03715.22
5.4.140.0050.02813.65
5.4.130.0110.01613.89
5.4.120.0030.03413.80
5.4.110.0050.04113.81
5.4.100.0020.02313.79
5.4.90.0040.02513.89
5.4.80.0000.02613.70
5.4.70.0050.02713.82
5.4.60.0070.03313.80
5.4.50.0050.03913.87
5.4.40.0080.02013.66
5.4.30.0010.02313.82
5.4.20.0100.02513.88
5.4.10.0030.04013.69
5.4.00.0070.03213.37
5.3.290.0050.03912.72
5.3.280.0030.03012.74
5.3.270.0050.03612.72
5.3.260.0050.03512.71
5.3.250.0090.03812.74
5.3.240.0020.02512.70
5.3.230.0060.03212.72
5.3.220.0050.02312.72
5.3.210.0040.04412.69
5.3.200.0050.03212.72
5.3.190.0070.04312.72
5.3.180.0050.02512.60
5.3.170.0070.02012.80
5.3.160.0020.03512.69
5.3.150.0070.03712.74
5.3.140.0020.04112.72
5.3.130.0020.02312.70
5.3.120.0030.03712.71
5.3.110.0080.03012.66
5.3.100.0020.02312.44
5.3.90.0000.02412.39
5.3.80.0080.03512.43
5.3.70.0020.03012.44
5.3.60.0050.04212.52
5.3.50.0000.04112.43
5.3.40.0100.01512.39
5.3.30.0070.03912.39
5.3.20.0100.02112.28
5.3.10.0050.04212.34
5.3.00.0020.03912.33
5.2.170.0000.07011.18
5.2.160.0000.03311.05
5.2.150.0070.02711.14
5.2.140.0070.02711.21
5.2.130.0030.05711.00
5.2.120.0000.06011.19
5.2.110.0130.05711.13
5.2.100.0000.04011.02
5.2.90.0170.05011.13
5.2.80.0070.05711.13
5.2.70.0170.03011.07
5.2.60.0030.04011.11
5.2.50.0030.03011.00
5.2.40.0100.05711.07
5.2.30.0000.03310.98
5.2.20.0000.04711.07
5.2.10.0070.06010.92
5.2.00.0030.06710.79
5.1.60.0070.05010.07
5.1.50.0070.05010.00
5.1.40.0030.02710.07
5.1.30.0030.06010.40
5.1.20.0030.04710.33
5.1.10.0000.04310.00
5.1.00.0070.04310.29
5.0.50.0100.0438.71
5.0.40.0030.0408.71
5.0.30.0000.0408.71
5.0.20.0000.0208.71
5.0.10.0100.0338.71
5.0.00.0070.0508.71
4.4.90.0000.0208.71
4.4.80.0070.0308.71
4.4.70.0030.0408.71
4.4.60.0070.0278.71
4.4.50.0070.0208.71
4.4.40.0030.0508.71
4.4.30.0000.0278.71
4.4.20.0000.0338.71
4.4.10.0030.0308.71
4.4.00.0070.0278.71
4.3.110.0030.0238.71
4.3.100.0000.0178.71
4.3.90.0030.0278.71
4.3.80.0070.0378.71
4.3.70.0070.0308.71
4.3.60.0000.0378.71
4.3.50.0030.0338.71
4.3.40.0070.0508.71
4.3.30.0000.0208.71
4.3.20.0000.0178.71
4.3.10.0030.0338.71
4.3.00.0000.0178.71

preferences:
42.28 ms | 401 KiB | 5 Q