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(\/(?:home|default|index)\..{3,4})$2", $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?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.0070.00717.00
8.3.50.0080.01217.55
8.3.40.0180.00018.98
8.3.30.0080.00818.96
8.3.20.0080.00019.08
8.3.10.0000.00820.65
8.3.00.0040.01219.51
8.2.180.0130.00316.75
8.2.170.0040.01422.96
8.2.160.0040.01119.64
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0000.00820.50
8.2.110.0090.00019.34
8.2.100.0110.00018.28
8.2.90.0040.00419.41
8.2.80.0020.00519.46
8.2.70.0090.00017.75
8.2.60.0000.00818.16
8.2.50.0030.00618.07
8.2.40.0090.00018.47
8.2.30.0000.00818.12
8.2.20.0040.00417.81
8.2.10.0050.00318.01
8.2.00.0050.00217.89
8.1.280.0150.00325.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0110.00023.73
8.1.230.0070.00421.02
8.1.220.0000.00817.91
8.1.210.0040.00419.09
8.1.200.0040.00417.60
8.1.190.0050.00317.75
8.1.180.0060.00318.10
8.1.170.0000.00818.86
8.1.160.0040.00419.01
8.1.150.0030.00518.78
8.1.140.0030.00517.82
8.1.130.0000.00817.88
8.1.120.0040.00417.59
8.1.110.0050.00317.70
8.1.100.0060.00317.63
8.1.90.0080.00017.69
8.1.80.0000.00717.54
8.1.70.0070.00017.64
8.1.60.0000.00917.68
8.1.50.0000.00917.58
8.1.40.0040.00417.64
8.1.30.0040.00417.73
8.1.20.0000.00817.76
8.1.10.0040.00417.62
8.1.00.0040.00417.54
8.0.300.0040.00419.90
8.0.290.0000.00716.88
8.0.280.0070.00018.59
8.0.270.0000.00817.38
8.0.260.0040.00417.09
8.0.250.0080.00017.16
8.0.240.0000.00717.16
8.0.230.0060.00317.05
8.0.220.0030.00317.14
8.0.210.0030.00617.12
8.0.200.0030.00317.21
8.0.190.0060.00317.20
8.0.180.0000.00817.11
8.0.170.0050.00516.99
8.0.160.0040.00417.02
8.0.150.0040.00716.95
8.0.140.0000.01017.07
8.0.130.0000.00613.54
8.0.120.0040.00417.11
8.0.110.0050.00317.19
8.0.100.0040.00417.13
8.0.90.0040.00417.06
8.0.80.0190.00317.20
8.0.70.0030.00517.05
8.0.60.0070.00017.02
8.0.50.0000.00817.05
8.0.30.0140.00617.12
8.0.20.0120.01117.36
8.0.10.0040.00417.32
8.0.00.0120.01217.05
7.4.330.0000.00513.25
7.4.320.0030.00316.98
7.4.300.0030.00316.85
7.4.290.0040.00416.82
7.4.280.0030.00516.98
7.4.270.0000.00816.93
7.4.260.0030.00313.67
7.4.250.0040.00416.92
7.4.240.0040.00416.82
7.4.230.0000.00716.70
7.4.220.0030.01616.75
7.4.210.0080.01016.85
7.4.200.0040.00416.73
7.4.190.0040.00417.04
7.4.160.0030.01316.85
7.4.150.0140.00416.80
7.4.140.0100.01116.81
7.4.130.0140.00316.76
7.4.120.0120.00716.92
7.4.110.0090.00916.90
7.4.100.0090.00916.89
7.4.90.0090.00916.75
7.4.80.0060.01216.71
7.4.70.0080.00916.72
7.4.60.0070.01316.67
7.4.50.0090.00316.64
7.4.40.0040.01116.72
7.4.30.0070.01016.71
7.4.00.0070.00715.32
7.3.330.0030.00313.47
7.3.320.0000.00613.50
7.3.310.0050.00216.36
7.3.300.0000.00716.55
7.3.290.0060.00916.48
7.3.280.0090.01016.51
7.3.270.0180.00616.64
7.3.260.0130.00616.55
7.3.250.0070.01316.57
7.3.240.0140.00316.66
7.3.230.0140.00416.96
7.3.210.0090.00916.50
7.3.200.0110.00819.39
7.3.190.0070.01516.88
7.3.180.0000.01616.69
7.3.170.0150.00416.73
7.3.160.0000.01616.54
7.3.120.0090.00615.09
7.2.330.0040.01516.99
7.2.320.0130.01016.95
7.2.310.0090.01216.66
7.2.300.0090.00616.80
7.2.290.0140.00316.85
7.2.00.0070.00319.55
7.1.100.0100.00618.37
7.1.70.0030.00717.29
7.1.60.0070.01719.40
7.1.50.0030.01917.23
7.1.00.0030.03722.36
7.0.200.0040.00815.13
7.0.140.0030.07022.08
7.0.120.0070.05722.09
7.0.60.0170.08019.80
7.0.50.0100.05718.00
7.0.40.0170.07317.83
7.0.30.0070.08017.75
7.0.20.0070.08317.75
7.0.10.0070.05017.80
7.0.00.0100.08017.71
5.6.280.0030.07320.78
5.6.210.0070.08020.70
5.6.200.0100.06718.25
5.6.190.0070.04718.18
5.6.180.0030.08718.18
5.6.170.0070.08318.18
5.6.160.0030.05018.18
5.6.150.0130.07318.28
5.6.140.0070.08318.18
5.6.130.0130.07718.18
5.6.120.0030.04318.22
5.6.110.0130.05718.28
5.6.100.0130.07018.27
5.6.90.0100.05318.17
5.6.80.0000.06017.67
5.6.70.0100.03317.57
5.6.60.0070.06317.52
5.6.50.0100.03717.68
5.6.40.0170.06717.54
5.6.30.0130.03017.55
5.6.20.0030.05017.54
5.6.10.0100.07317.63
5.6.00.0070.04717.53
5.5.350.0300.05020.41
5.5.340.0170.06718.02
5.5.330.0100.06317.95
5.5.320.0070.08017.95
5.5.310.0030.06317.94
5.5.300.0100.05718.05
5.5.290.0100.03718.02
5.5.280.0030.08717.96
5.5.270.0000.05317.95
5.5.260.0030.04717.94
5.5.250.0130.07717.86
5.5.240.0000.04717.36
5.5.230.0200.07017.37
5.5.220.0000.05717.33
5.5.210.0070.08017.32
5.5.200.0100.04317.35
5.5.190.0030.05717.34
5.5.180.0170.04317.34
5.5.160.0000.05017.39
5.5.150.0130.03017.42
5.5.140.0000.04017.38
5.5.130.0000.04017.30
5.5.120.0070.04017.38
5.5.110.0030.03717.34
5.5.100.0000.04017.24
5.5.90.0100.03717.19
5.5.80.0000.04317.20
5.5.70.0130.03717.32
5.5.60.0030.03717.21
5.5.50.0030.03717.32
5.5.40.0030.03717.23
5.5.30.0070.03317.20
5.5.20.0030.03717.21
5.5.10.0070.03317.37
5.5.00.0030.04017.21
5.4.450.0070.04019.38
5.4.440.0130.06719.38
5.4.430.0070.08319.58
5.4.420.0030.05719.58
5.4.410.0070.06319.24
5.4.400.0200.05319.05
5.4.390.0130.07018.90
5.4.380.0030.05319.07
5.4.370.0070.07718.96
5.4.360.0100.07719.02
5.4.350.0070.04018.95
5.4.340.0000.06318.98
5.4.320.0030.04019.03
5.4.310.0070.03318.95
5.4.300.0100.03319.03
5.4.290.0030.03718.98
5.4.280.0070.03319.09
5.4.270.0100.03319.00
5.4.260.0030.04719.01
5.4.250.0030.03718.96
5.4.240.0000.04019.09
5.4.230.0030.03719.08
5.4.220.0100.03019.00
5.4.210.0000.04319.04
5.4.200.0000.04018.99
5.4.190.0030.03719.02
5.4.180.0030.03719.11
5.4.170.0100.03018.88
5.4.160.0030.03719.00
5.4.150.0000.04019.11
5.4.140.0030.05016.48
5.4.130.0030.03316.38
5.4.120.0000.03716.33
5.4.110.0030.04716.28
5.4.100.0030.03316.47
5.4.90.0000.03716.63
5.4.80.0000.08016.61
5.4.70.0030.03316.58
5.4.60.0070.07316.45
5.4.50.0070.07016.32
5.4.40.0000.07716.32
5.4.30.0070.07716.35
5.4.20.0130.03716.39
5.4.10.0070.07016.20
5.4.00.0030.03715.84
5.3.290.0030.04014.71
5.3.280.0030.03714.64
5.3.270.0000.04014.66
5.3.260.0100.05314.68
5.3.250.0070.05014.72
5.3.240.0030.03314.63
5.3.230.0100.03014.55
5.3.220.0000.04014.41
5.3.210.0030.03714.78
5.3.200.0030.03714.59
5.3.190.0070.05714.56
5.3.180.0030.03714.63
5.3.170.0030.06014.63
5.3.160.0070.06314.60
5.3.150.0070.05014.61
5.3.140.0070.07314.63
5.3.130.0100.07714.59
5.3.120.0100.07714.76
5.3.110.0070.03714.76
5.3.100.0070.05014.09
5.3.90.0100.06714.03
5.3.80.0100.04313.90
5.3.70.0030.05314.01
5.3.60.0100.05014.05
5.3.50.0070.07313.99
5.3.40.0130.03714.02
5.3.30.0070.06713.90
5.3.20.0130.05713.70
5.3.10.0070.03713.66
5.3.00.0100.07313.63
5.2.170.0030.06711.13
5.2.160.0100.05711.18
5.2.150.0030.03011.21
5.2.140.0070.06011.18
5.2.130.0070.03711.14
5.2.120.0070.03011.09
5.2.110.0000.03311.14
5.2.100.0070.05711.11
5.2.90.0030.04011.15
5.2.80.0070.04711.13
5.2.70.0070.05711.10
5.2.60.0100.05710.94
5.2.50.0030.03711.02
5.2.40.0000.06311.21
5.2.30.0000.06310.96
5.2.20.0000.03711.08
5.2.10.0100.04010.89
5.2.00.0030.05010.83
5.1.60.0100.04710.00
5.1.50.0030.03010.05
5.1.40.0070.0509.93
5.1.30.0070.06010.24
5.1.20.0130.04310.38
5.1.10.0100.05310.29
5.1.00.0030.05010.18
5.0.50.0070.0478.59
5.0.40.0000.0478.50
5.0.30.0000.0378.07
5.0.20.0070.0378.20
5.0.10.0030.0278.16
5.0.00.0070.0638.27
4.4.90.0030.0177.43
4.4.80.0000.0207.43
4.4.70.0030.0237.43
4.4.60.0030.0337.43
4.4.50.0000.0307.43
4.4.40.0100.0337.43
4.4.30.0070.0277.43
4.4.20.0030.0237.43
4.4.10.0000.0407.43
4.4.00.0070.0407.43
4.3.110.0030.0337.43
4.3.100.0000.0207.43
4.3.90.0070.0137.43
4.3.80.0000.0537.43
4.3.70.0000.0377.43
4.3.60.0030.0377.43
4.3.50.0030.0137.43
4.3.40.0000.0277.43
4.3.30.0000.0207.43
4.3.20.0070.0337.43
4.3.10.0000.0377.43
4.3.00.0070.0307.43

preferences:
41.55 ms | 400 KiB | 5 Q