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?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.0100.00618.53
8.3.50.0110.00816.75
8.3.40.0120.00618.96
8.3.30.0040.01218.96
8.3.20.0090.00019.03
8.3.10.0050.00320.81
8.3.00.0080.00019.63
8.2.180.0120.00916.63
8.2.170.0140.00722.96
8.2.160.0110.00422.33
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0030.00619.89
8.2.110.0070.01522.41
8.2.100.0090.00317.97
8.2.90.0080.00019.30
8.2.80.0000.00819.40
8.2.70.0050.00517.75
8.2.60.0040.00418.03
8.2.50.0080.00018.07
8.2.40.0030.00518.16
8.2.30.0000.00818.18
8.2.20.0000.00817.91
8.2.10.0000.00817.82
8.2.00.0000.00917.84
8.1.280.0110.01125.92
8.1.270.0040.00423.99
8.1.260.0080.00826.35
8.1.250.0060.00328.09
8.1.240.0070.00422.50
8.1.230.0040.00821.23
8.1.220.0000.00817.78
8.1.210.0000.00819.09
8.1.200.0030.00617.48
8.1.190.0030.00517.54
8.1.180.0000.01118.10
8.1.170.0000.00819.04
8.1.160.0050.00219.01
8.1.150.0000.00818.82
8.1.140.0040.00417.77
8.1.130.0000.00717.95
8.1.120.0050.00317.61
8.1.110.0030.00617.66
8.1.100.0050.00317.54
8.1.90.0040.00417.57
8.1.80.0080.00017.56
8.1.70.0030.00317.61
8.1.60.0040.00417.81
8.1.50.0030.00517.55
8.1.40.0000.00917.60
8.1.30.0050.00317.72
8.1.20.0040.00417.70
8.1.10.0000.00817.64
8.1.00.0040.00417.65
8.0.300.0040.00420.07
8.0.290.0000.00816.88
8.0.280.0030.00518.38
8.0.270.0050.00317.24
8.0.260.0030.00317.00
8.0.250.0030.00617.17
8.0.240.0070.00417.11
8.0.230.0000.00717.14
8.0.220.0030.00317.11
8.0.210.0000.00717.12
8.0.200.0070.00017.11
8.0.190.0040.00417.17
8.0.180.0040.00417.09
8.0.170.0040.00417.13
8.0.160.0020.00517.18
8.0.150.0060.00316.93
8.0.140.0090.00617.07
8.0.130.0060.00013.47
8.0.120.0050.00317.09
8.0.110.0080.00017.14
8.0.100.0040.00417.07
8.0.90.0080.00017.12
8.0.80.0090.00617.10
8.0.70.0070.00017.03
8.0.60.0000.00717.10
8.0.50.0000.00717.08
8.0.30.0080.01217.38
8.0.20.0090.01217.34
8.0.10.0070.00017.15
8.0.00.0150.00916.96
7.4.330.0030.00314.94
7.4.320.0000.00916.92
7.4.300.0030.00316.71
7.4.290.0040.00416.93
7.4.280.0040.00416.73
7.4.270.0030.00316.71
7.4.260.0030.00313.58
7.4.250.0040.00416.93
7.4.240.0050.00216.72
7.4.230.0090.00016.75
7.4.220.0120.00916.80
7.4.210.0070.01016.85
7.4.200.0040.00417.01
7.4.190.0040.00416.92
7.4.160.0110.00616.70
7.4.150.0060.01117.18
7.4.140.0150.00717.36
7.4.130.0130.00516.88
7.4.120.0090.00916.90
7.4.110.0070.01116.63
7.4.100.0060.01216.54
7.4.90.0100.00816.78
7.4.80.0120.00618.80
7.4.70.0090.01216.72
7.4.60.0160.00016.88
7.4.50.0060.00316.74
7.4.40.0150.00022.27
7.4.30.0070.01116.69
7.4.00.0000.01814.88
7.3.330.0000.00613.36
7.3.320.0030.00313.31
7.3.310.0040.00416.53
7.3.300.0000.00716.46
7.3.290.0100.01016.49
7.3.280.0110.00516.50
7.3.270.0040.01617.18
7.3.260.0110.00718.24
7.3.250.0160.00816.66
7.3.240.0100.00716.79
7.3.230.0150.00916.85
7.3.210.0060.01316.77
7.3.200.0150.00319.39
7.3.190.0100.01416.66
7.3.180.0130.00316.86
7.3.170.0100.00716.80
7.3.160.0130.01016.52
7.3.120.0110.00415.07
7.2.330.0120.01217.02
7.2.320.0030.01416.71
7.2.310.0070.01116.97
7.2.300.0080.00816.83
7.2.290.0030.01416.83
7.2.00.0070.00719.42
7.1.100.0080.00418.49
7.1.70.0040.00717.42
7.1.60.0140.01119.40
7.1.50.0000.01717.22
7.1.00.0030.06722.34
7.0.200.0070.00316.72
7.0.140.0130.06321.92
7.0.60.0170.08021.71
7.0.50.0030.04017.92
7.0.40.0100.03317.88
7.0.30.0030.04017.84
7.0.20.0030.04317.72
7.0.10.0000.04317.77
7.0.00.0030.04017.87
5.6.280.0000.07321.11
5.6.210.0070.08320.48
5.6.200.0030.06718.16
5.6.190.0200.03318.18
5.6.180.0030.04018.25
5.6.170.0030.04018.14
5.6.160.0030.04018.16
5.6.150.0070.03718.19
5.6.140.0030.03718.28
5.6.130.0100.03318.18
5.6.120.0000.04318.15
5.6.110.0000.04318.20
5.6.100.0030.04018.17
5.6.90.0070.03718.27
5.6.80.0000.04017.57
5.6.70.0030.03717.54
5.6.60.0030.03717.56
5.6.50.0000.04317.56
5.6.40.0030.03717.52
5.6.30.0070.04017.59
5.6.20.0070.05017.60
5.6.10.0030.04017.70
5.6.00.0030.06717.50
5.5.350.0030.08320.44
5.5.340.0000.04718.04
5.5.330.0030.05717.99
5.5.320.0000.04018.07
5.5.310.0130.03717.92
5.5.300.0000.04718.08
5.5.290.0100.03317.98
5.5.280.0030.04018.07
5.5.270.0030.04017.93
5.5.260.0000.04318.04
5.5.250.0070.03317.80
5.5.240.0030.03717.31
5.5.230.0030.03717.34
5.5.220.0030.03717.38
5.5.210.0030.04017.34
5.5.200.0030.03717.34
5.5.190.0000.04017.33
5.5.180.0070.06717.40
5.5.160.0100.07317.44
5.5.150.0230.06017.38
5.5.140.0100.05317.30
5.5.130.0030.04017.32
5.5.120.0070.04317.29
5.5.110.0030.09017.43
5.5.100.0070.07717.32
5.5.90.0130.04317.29
5.5.80.0070.05717.30
5.5.70.0130.07017.34
5.5.60.0070.04717.23
5.5.50.0030.06717.25
5.5.40.0070.04317.27
5.5.30.0070.05317.18
5.5.20.0000.04717.15
5.5.10.0070.06017.29
5.5.00.0170.07017.22
5.4.450.0030.03719.43
5.4.440.0030.03719.31
5.4.430.0070.03719.45
5.4.420.0000.04019.21
5.4.410.0070.03319.34
5.4.400.0100.03319.14
5.4.390.0070.03319.12
5.4.380.0030.03719.05
5.4.370.0070.05319.05
5.4.360.0000.04019.07
5.4.350.0000.04019.03
5.4.340.0070.03719.02
5.4.320.0030.04718.95
5.4.310.0130.03719.04
5.4.300.0030.05319.10
5.4.290.0030.06319.27
5.4.280.0030.06319.05
5.4.270.0170.03019.11
5.4.260.0070.04719.12
5.4.250.0170.04019.12
5.4.240.0030.05718.95
5.4.230.0070.04318.88
5.4.220.0030.06719.02
5.4.210.0030.04318.88
5.4.200.0070.05319.13
5.4.190.0070.07719.13
5.4.180.0070.07318.95
5.4.170.0170.07019.26
5.4.160.0070.06019.11
5.4.150.0070.06019.10
5.4.140.0070.07016.41
5.4.130.0030.03716.44
5.4.120.0000.04016.29
5.4.110.0070.05716.48
5.4.100.0170.06016.47
5.4.90.0130.06716.44
5.4.80.0000.07716.49
5.4.70.0030.06716.41
5.4.60.0000.06016.46
5.4.50.0100.06716.56
5.4.40.0170.06316.50
5.4.30.0100.05016.29
5.4.20.0130.05016.52
5.4.10.0070.07716.29
5.4.00.0070.06716.02
5.3.290.0070.04314.66
5.3.280.0100.04014.57
5.3.270.0070.03714.71
5.3.260.0030.07314.65
5.3.250.0000.08014.68
5.3.240.0070.04714.61
5.3.230.0030.05014.63
5.3.220.0100.07314.57
5.3.210.0070.06314.63
5.3.200.0000.06014.57
5.3.190.0070.05714.55
5.3.180.0070.07014.61
5.3.170.0100.07714.78
5.3.160.0070.08014.55
5.3.150.0030.07714.66
5.3.140.0030.08014.63
5.3.130.0100.07714.61
5.3.120.0070.08014.39
5.3.110.0130.06714.56
5.3.100.0030.08013.99
5.3.90.0070.07314.05
5.3.80.0100.05714.08
5.3.70.0200.06314.05
5.3.60.0200.06014.04
5.3.50.0070.07314.00
5.3.40.0100.07014.01
5.3.30.0000.06013.99
5.3.20.0030.05313.70
5.3.10.0030.04313.70
5.3.00.0030.04313.68
5.2.170.0070.06311.36
5.2.160.0100.05011.18
5.2.150.0030.05711.19
5.2.140.0070.06311.14
5.2.130.0070.06011.11
5.2.120.0100.07311.13
5.2.110.0030.05011.10
5.2.100.0030.03311.14
5.2.90.0100.04011.14
5.2.80.0100.05711.00
5.2.70.0030.06311.15
5.2.60.0070.04011.04
5.2.50.0070.06011.09
5.2.40.0000.05310.86
5.2.30.0070.06310.96
5.2.20.0030.03011.19
5.2.10.0070.05710.76
5.2.00.0070.05010.62
5.1.60.0000.0339.92
5.1.50.0030.02310.03
5.1.40.0070.0409.96
5.1.30.0000.03310.36
5.1.20.0000.06010.36
5.1.10.0000.03310.28
5.1.00.0030.03310.06
5.0.50.0030.0508.63
5.0.40.0070.0238.53
5.0.30.0100.0538.21
5.0.20.0000.0308.23
5.0.10.0000.0508.18
5.0.00.0000.0608.20
4.4.90.0000.0377.66
4.4.80.0000.0237.66
4.4.70.0000.0407.66
4.4.60.0030.0307.66
4.4.50.0030.0377.66
4.4.40.0030.0237.66
4.4.30.0030.0377.66
4.4.20.0030.0337.66
4.4.10.0030.0377.66
4.4.00.0030.0577.66
4.3.110.0000.0377.66
4.3.100.0030.0237.66
4.3.90.0030.0337.66
4.3.80.0000.0577.66
4.3.70.0100.0307.66
4.3.60.0030.0307.66
4.3.50.0030.0237.66
4.3.40.0030.0607.66
4.3.30.0030.0237.66
4.3.20.0070.0177.66
4.3.10.0000.0207.66
4.3.00.0030.0177.66

preferences:
41.61 ms | 401 KiB | 5 Q