3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remove_index_etc($url) { echo preg_match('/[\?#]/',$url); $isLastCharPattern = substr($url,-1) == "*"; if ($isLastCharPattern && preg_match('/[\?#]/',$url)) { $url = preg_replace('/^(.*)(?:\/(?:home|default|index)\..{3,4})([\?\/#\*]+.*)?$/i', "$1$4", $url); } elseif($isLastCharPattern) { $url = preg_replace('/^(.*)(?:\/(?:home|default|index)\..{3,4})([\?\/#\*]+.*)*$/i', "$1$2", $url); } else { $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/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.00718.68
8.3.50.0150.00916.54
8.3.40.0150.00318.92
8.3.30.0130.00918.97
8.3.20.0140.00718.84
8.3.10.0060.00320.64
8.3.00.0090.00017.63
8.2.180.0040.01216.63
8.2.170.0040.01122.96
8.2.160.0070.00722.33
8.2.150.0050.00324.18
8.2.140.0110.00724.66
8.2.130.0040.00426.16
8.2.120.0040.00420.08
8.2.110.0090.00019.33
8.2.100.0040.00818.16
8.2.90.0030.00619.17
8.2.80.0040.00417.97
8.2.70.0030.00617.75
8.2.60.0000.00818.03
8.2.50.0050.00318.07
8.2.40.0000.00818.22
8.2.30.0050.00518.30
8.2.20.0040.00417.91
8.2.10.0000.00817.91
8.2.00.0030.00817.98
8.1.280.0110.00725.92
8.1.270.0000.00823.99
8.1.260.0040.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00622.20
8.1.230.0080.00420.78
8.1.220.0060.00317.74
8.1.210.0060.00318.77
8.1.200.0030.00617.61
8.1.190.0000.00817.65
8.1.180.0050.00318.10
8.1.170.0040.00419.02
8.1.160.0040.00418.93
8.1.150.0000.00818.75
8.1.140.0040.00417.76
8.1.130.0070.00017.93
8.1.120.0040.00417.54
8.1.110.0040.00417.69
8.1.100.0040.00417.52
8.1.90.0050.00217.55
8.1.80.0050.00317.54
8.1.70.0000.00717.56
8.1.60.0080.00417.75
8.1.50.0040.00417.63
8.1.40.0000.00817.75
8.1.30.0050.00517.76
8.1.20.0000.00817.83
8.1.10.0080.00017.74
8.1.00.0030.00617.64
8.0.300.0000.00718.77
8.0.290.0060.00316.88
8.0.280.0030.00318.48
8.0.270.0000.00717.31
8.0.260.0000.00716.87
8.0.250.0040.00417.14
8.0.240.0100.00017.17
8.0.230.0030.00317.16
8.0.220.0040.00417.14
8.0.210.0000.00717.08
8.0.200.0070.00017.20
8.0.190.0040.00317.14
8.0.180.0070.00017.12
8.0.170.0040.00417.07
8.0.160.0040.00417.00
8.0.150.0050.00317.03
8.0.140.0060.00516.98
8.0.130.0030.00313.46
8.0.120.0080.00017.09
8.0.110.0000.00817.22
8.0.100.0000.00817.25
8.0.90.0000.00817.19
8.0.80.0060.00917.09
8.0.70.0040.00417.03
8.0.60.0040.00417.01
8.0.50.0000.00717.18
8.0.30.0130.00617.26
8.0.20.0130.00917.45
8.0.10.0050.00317.17
8.0.00.0090.01017.00
7.4.330.0000.00615.01
7.4.320.0030.00316.87
7.4.300.0000.00616.80
7.4.290.0000.00816.74
7.4.280.0040.00416.80
7.4.270.0000.00816.83
7.4.260.0060.00313.56
7.4.250.0060.00316.89
7.4.240.0040.00416.80
7.4.230.0070.00016.93
7.4.220.0070.01416.92
7.4.210.0090.00716.87
7.4.200.0030.00316.89
7.4.190.0070.00016.82
7.4.160.0160.00016.79
7.4.150.0140.00317.18
7.4.140.0120.00517.31
7.4.130.0130.00516.84
7.4.120.0140.00316.78
7.4.110.0180.00416.68
7.4.100.0120.00616.73
7.4.90.0040.01216.86
7.4.80.0090.00918.80
7.4.70.0100.00616.84
7.4.60.0160.00016.82
7.4.50.0050.00216.72
7.4.40.0080.00822.27
7.4.30.0040.01216.85
7.4.00.0110.00414.86
7.3.330.0030.00313.39
7.3.320.0000.00813.54
7.3.310.0030.00316.48
7.3.300.0040.00416.49
7.3.290.0090.00616.46
7.3.280.0070.00816.50
7.3.270.0090.01617.18
7.3.260.0070.01018.24
7.3.250.0110.01016.56
7.3.240.0100.00716.56
7.3.230.0090.00916.57
7.3.210.0130.00316.99
7.3.200.0080.00816.38
7.3.190.0180.00416.62
7.3.180.0060.01116.56
7.3.170.0050.01716.54
7.3.160.0100.01416.92
7.3.120.0120.00615.21
7.2.330.0080.01016.77
7.2.320.0110.00716.87
7.2.310.0140.00916.98
7.2.300.0160.00316.93
7.2.290.0060.01216.66
7.2.00.0070.00719.57
7.1.100.0100.00318.15
7.1.70.0070.01017.30
7.1.60.0030.01319.40
7.1.50.0040.01917.12
7.1.00.0030.03322.46
7.0.200.0000.00716.84
7.0.140.0030.07322.09
7.0.60.0100.07019.96
7.0.50.0000.08017.81
7.0.40.0100.05017.86
7.0.30.0100.07317.78
7.0.20.0130.06017.89
7.0.10.0100.06717.88
7.0.00.0200.06717.84
5.6.280.0070.07021.14
5.6.210.0130.08020.73
5.6.200.0070.07718.21
5.6.190.0100.04318.18
5.6.180.0070.07318.28
5.6.170.0070.08718.18
5.6.160.0000.08018.14
5.6.150.0070.08318.18
5.6.140.0200.07018.15
5.6.130.0070.07718.11
5.6.120.0130.07318.27
5.6.110.0030.07018.15
5.6.100.0100.07018.24
5.6.90.0130.07718.16
5.6.80.0030.08317.60
5.6.70.0100.03317.62
5.6.60.0100.04717.53
5.6.50.0030.05317.57
5.6.40.0070.06717.53
5.6.30.0030.07717.54
5.6.20.0000.07017.63
5.6.10.0070.06317.52
5.6.00.0030.07017.53
5.5.350.0030.08320.41
5.5.340.0130.07717.94
5.5.330.0130.06717.98
5.5.320.0030.04717.96
5.5.310.0070.08018.00
5.5.300.0100.04718.08
5.5.290.0070.04717.99
5.5.280.0130.03318.05
5.5.270.0070.07317.99
5.5.260.0100.04717.98
5.5.250.0030.08317.80
5.5.240.0070.06717.38
5.5.230.0070.03717.34
5.5.220.0070.03717.41
5.5.210.0070.04717.36
5.5.200.0100.04317.34
5.5.190.0030.08017.32
5.5.180.0100.06717.34
5.5.160.0100.05017.28
5.5.150.0070.04317.34
5.5.140.0130.04717.30
5.5.130.0130.07017.30
5.5.120.0100.07717.30
5.5.110.0030.08317.36
5.5.100.0130.07017.20
5.5.90.0070.06717.16
5.5.80.0030.07017.24
5.5.70.0030.05717.22
5.5.60.0130.04017.29
5.5.50.0130.05717.22
5.5.40.0030.04317.19
5.5.30.0000.08017.31
5.5.20.0130.06317.16
5.5.10.0030.06017.26
5.5.00.0070.06717.25
5.4.450.0130.07019.39
5.4.440.0000.04719.38
5.4.430.0100.06319.31
5.4.420.0130.04019.38
5.4.410.0130.06719.25
5.4.400.0030.07719.27
5.4.390.0100.03319.13
5.4.380.0100.05719.03
5.4.370.0000.05719.07
5.4.360.0070.05019.04
5.4.350.0070.08019.02
5.4.340.0100.04319.05
5.4.320.0130.06019.04
5.4.310.0070.05318.95
5.4.300.0100.03319.00
5.4.290.0130.06319.05
5.4.280.0070.07319.05
5.4.270.0170.06719.11
5.4.260.0070.08019.03
5.4.250.0070.06319.01
5.4.240.0130.07018.95
5.4.230.0130.05319.00
5.4.220.0100.06319.04
5.4.210.0130.04319.09
5.4.200.0030.04019.02
5.4.190.0070.04319.03
5.4.180.0170.06319.01
5.4.170.0100.07319.04
5.4.160.0030.07318.87
5.4.150.0100.07318.99
5.4.140.0170.04716.63
5.4.130.0030.06316.47
5.4.120.0030.06716.44
5.4.110.0100.05016.43
5.4.100.0070.04316.61
5.4.90.0030.07716.35
5.4.80.0030.07016.42
5.4.70.0070.03716.42
5.4.60.0100.06016.35
5.4.50.0070.05016.41
5.4.40.0000.06716.27
5.4.30.0130.04016.38
5.4.20.0130.06016.35
5.4.10.0000.04316.37
5.4.00.0100.04315.85
5.3.290.0070.07314.74
5.3.280.0030.06014.59
5.3.270.0030.05714.71
5.3.260.0100.08014.63
5.3.250.0100.06314.67
5.3.240.0000.08314.46
5.3.230.0100.06714.62
5.3.220.0000.07014.42
5.3.210.0030.08014.42
5.3.200.0070.06714.61
5.3.190.0100.04014.60
5.3.180.0000.04714.41
5.3.170.0100.07314.57
5.3.160.0070.07314.52
5.3.150.0070.07714.61
5.3.140.0070.04314.57
5.3.130.0070.06714.58
5.3.120.0000.05314.57
5.3.110.0070.04714.40
5.3.100.0030.07014.10
5.3.90.0070.07714.01
5.3.80.0130.06013.91
5.3.70.0030.04313.91
5.3.60.0100.07314.02
5.3.50.0100.07013.81
5.3.40.0130.05714.02
5.3.30.0130.06013.95
5.3.20.0070.07013.69
5.3.10.0100.06013.50
5.3.00.0100.03713.67
5.2.170.0030.04011.19
5.2.160.0100.05711.36
5.2.150.0070.06711.25
5.2.140.0100.05710.99
5.2.130.0100.03011.16
5.2.120.0100.03310.95
5.2.110.0070.03311.15
5.2.100.0070.06011.00
5.2.90.0070.03711.11
5.2.80.0070.06011.00
5.2.70.0130.03011.19
5.2.60.0070.04010.90
5.2.50.0030.05711.01
5.2.40.0030.05011.06
5.2.30.0030.03711.02
5.2.20.0100.05710.93
5.2.10.0000.06011.07
5.2.00.0030.06310.78
5.1.60.0000.0579.99
5.1.50.0000.03710.06
5.1.40.0030.05710.02
5.1.30.0030.05710.34
5.1.20.0030.03710.38
5.1.10.0030.04310.28
5.1.00.0030.03710.28
5.0.50.0070.0278.51
5.0.40.0030.0338.34
5.0.30.0000.0608.21
5.0.20.0030.0278.25
5.0.10.0000.0338.21
5.0.00.0030.0438.08
4.4.90.0000.0337.83
4.4.80.0070.0177.83
4.4.70.0000.0377.83
4.4.60.0000.0377.83
4.4.50.0000.0277.83
4.4.40.0070.0437.83
4.4.30.0030.0237.83
4.4.20.0030.0407.83
4.4.10.0030.0307.83
4.4.00.0000.0607.83
4.3.110.0000.0277.83
4.3.100.0030.0377.83
4.3.90.0000.0207.83
4.3.80.0000.0307.83
4.3.70.0000.0177.83
4.3.60.0000.0177.83
4.3.50.0000.0177.83
4.3.40.0000.0237.83
4.3.30.0000.0207.83
4.3.20.0030.0137.83
4.3.10.0030.0137.83
4.3.00.0030.0107.83

preferences:
47.2 ms | 400 KiB | 5 Q