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)?$3", $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.70.0160.00617.00
8.3.60.0040.01218.56
8.3.50.0130.00716.71
8.3.40.0130.00318.96
8.3.30.0090.00618.97
8.3.20.0080.00018.98
8.3.10.0040.00420.65
8.3.00.0030.00617.59
8.2.180.0060.00917.13
8.2.170.0000.01522.96
8.2.160.0080.00822.13
8.2.150.0030.00624.18
8.2.140.0070.01124.66
8.2.130.0080.00026.16
8.2.120.0050.00220.02
8.2.110.0070.00321.12
8.2.100.0000.01217.84
8.2.90.0080.00017.75
8.2.80.0070.00317.97
8.2.70.0050.00517.92
8.2.60.0000.00917.77
8.2.50.0030.00618.10
8.2.40.0060.00320.61
8.2.30.0040.00418.25
8.2.20.0040.00417.97
8.2.10.0030.00517.84
8.2.00.0080.00017.91
8.1.280.0110.00725.92
8.1.270.0050.00323.99
8.1.260.0120.00326.35
8.1.250.0110.00428.09
8.1.240.0000.00923.88
8.1.230.0120.00020.78
8.1.220.0040.00417.89
8.1.210.0060.00318.77
8.1.200.0030.00617.60
8.1.190.0030.00617.48
8.1.180.0000.00918.10
8.1.170.0030.00518.89
8.1.160.0050.00319.04
8.1.150.0000.00818.93
8.1.140.0000.00817.65
8.1.130.0070.00018.02
8.1.120.0000.00717.67
8.1.110.0000.00917.60
8.1.100.0050.00317.69
8.1.90.0030.00617.64
8.1.80.0030.00517.66
8.1.70.0030.00317.59
8.1.60.0060.00317.79
8.1.50.0000.00917.65
8.1.40.0080.00017.77
8.1.30.0000.00817.80
8.1.20.0030.00517.87
8.1.10.0080.00017.73
8.1.00.0080.00017.55
8.0.300.0070.00020.02
8.0.290.0040.00816.85
8.0.280.0030.00318.48
8.0.270.0000.00717.23
8.0.260.0030.00317.05
8.0.250.0060.00317.06
8.0.240.0070.00317.15
8.0.230.0000.00717.03
8.0.220.0000.00717.04
8.0.210.0000.00817.01
8.0.200.0000.00717.02
8.0.190.0030.00617.15
8.0.180.0000.00717.16
8.0.170.0000.00817.14
8.0.160.0040.00417.07
8.0.150.0050.00317.07
8.0.140.0000.01016.93
8.0.130.0060.00013.55
8.0.120.0040.00417.07
8.0.110.0060.00317.04
8.0.100.0030.00516.92
8.0.90.0000.00717.27
8.0.80.0120.00417.19
8.0.70.0050.00217.00
8.0.60.0040.00417.04
8.0.50.0070.00017.10
8.0.30.0140.01117.29
8.0.20.0060.01417.23
8.0.10.0040.00417.13
8.0.00.0090.01216.97
7.4.330.0000.00515.06
7.4.320.0000.00716.97
7.4.300.0030.00316.82
7.4.290.0000.00716.96
7.4.280.0080.00016.82
7.4.270.0030.00516.75
7.4.260.0000.00713.70
7.4.250.0000.00816.90
7.4.240.0000.00716.79
7.4.230.0040.00416.66
7.4.220.0060.01216.86
7.4.210.0060.00916.90
7.4.200.0000.00817.00
7.4.190.0000.00716.98
7.4.160.0000.01616.90
7.4.150.0030.01517.18
7.4.140.0120.01017.28
7.4.130.0100.00916.87
7.4.120.0110.00716.64
7.4.110.0090.00916.88
7.4.100.0120.00616.79
7.4.90.0070.01116.78
7.4.80.0140.00618.80
7.4.70.0040.01816.70
7.4.60.0100.00616.59
7.4.50.0040.00416.57
7.4.40.0080.00522.27
7.4.30.0070.01516.62
7.4.00.0060.00915.15
7.3.330.0000.00713.29
7.3.320.0000.00613.44
7.3.310.0070.00016.57
7.3.300.0020.00516.55
7.3.290.0100.01016.41
7.3.280.0080.00916.48
7.3.270.0100.00717.18
7.3.260.0120.01018.24
7.3.250.0100.01316.68
7.3.240.0110.00616.47
7.3.230.0130.00316.51
7.3.210.0060.01216.53
7.3.200.0110.01116.87
7.3.190.0090.00916.60
7.3.180.0030.01316.77
7.3.170.0150.00316.40
7.3.160.0090.01216.53
7.3.120.0030.01014.77
7.3.10.0060.00916.89
7.3.00.0100.00716.31
7.2.330.0190.00316.88
7.2.320.0100.01016.79
7.2.310.0080.01116.89
7.2.300.0000.01616.87
7.2.290.0130.00316.85
7.2.130.0060.01116.66
7.2.120.0080.01316.55
7.2.110.0170.00317.03
7.2.100.0090.00916.86
7.2.90.0130.00716.86
7.2.80.0120.00316.64
7.2.70.0120.00816.96
7.2.60.0150.01216.75
7.2.50.0080.01216.92
7.2.40.0110.01116.99
7.2.30.0090.01217.10
7.2.20.0140.01016.81
7.2.10.0070.01516.89
7.2.00.0060.01418.23
7.1.250.0070.01115.81
7.1.100.0040.00718.36
7.1.70.0060.00317.46
7.1.60.0140.01019.40
7.1.50.0070.01416.94
7.1.00.0000.06722.50
7.0.200.0000.00816.81
7.0.140.0030.07722.01
7.0.60.0100.07320.09
7.0.50.0030.04018.04
7.0.40.0030.04017.75
7.0.30.0030.05317.83
7.0.20.0070.05017.89
7.0.10.0070.08017.82
7.0.00.0030.07717.81
5.6.210.0100.07720.54
5.6.200.0000.04318.16
5.6.190.0000.04718.29
5.6.180.0100.08018.29
5.6.170.0170.04018.28
5.6.160.0030.04318.23
5.6.150.0100.06318.23
5.6.140.0100.08318.19
5.6.130.0030.06318.21
5.6.120.0100.04718.18
5.6.110.0070.06718.18
5.6.100.0000.04718.20
5.6.90.0030.08318.17
5.6.80.0100.07317.63
5.6.70.0130.06317.56
5.6.60.0030.08317.56
5.6.50.0030.04317.54
5.6.40.0030.06717.59
5.6.30.0030.05717.51
5.6.20.0100.06317.57
5.6.10.0100.03317.49
5.6.00.0100.07717.56
5.5.350.0070.04720.53
5.5.340.0000.04017.92
5.5.330.0030.04017.96
5.5.320.0100.07318.04
5.5.310.0100.05717.92
5.5.300.0130.05317.98
5.5.290.0030.08717.96
5.5.280.0070.07017.95
5.5.270.0070.06318.00
5.5.260.0130.07017.97
5.5.250.0100.07317.75
5.5.240.0170.06317.33
5.5.230.0030.05317.39
5.5.220.0070.06017.43
5.5.210.0030.04717.31
5.5.200.0070.07317.34
5.5.190.0070.04317.32
5.5.180.0100.07317.27
5.5.160.0030.07317.34
5.5.150.0100.07017.30
5.5.140.0030.05017.38
5.5.130.0000.06317.44
5.5.120.0070.08017.27
5.5.110.0100.05317.33
5.5.100.0030.04017.25
5.5.90.0070.07017.33
5.5.80.0070.05717.33
5.5.70.0030.04717.32
5.5.60.0070.04717.21
5.5.50.0100.06017.18
5.5.40.0070.04017.23
5.5.30.0000.06717.28
5.5.20.0100.04017.21
5.5.10.0070.03717.21
5.5.00.0170.06717.21
5.4.450.0000.04719.29
5.4.440.0130.07019.36
5.4.430.0030.06019.27
5.4.420.0030.07719.37
5.4.410.0070.07719.32
5.4.400.0070.07319.05
5.4.390.0130.07018.89
5.4.380.0070.04719.04
5.4.370.0030.07718.95
5.4.360.0070.08019.09
5.4.350.0170.06719.27
5.4.340.0100.04018.95
5.4.320.0070.07718.98
5.4.310.0030.08019.03
5.4.300.0070.08019.13
5.4.290.0000.06019.12
5.4.280.0100.07719.05
5.4.270.0000.07019.09
5.4.260.0070.07019.05
5.4.250.0070.07319.02
5.4.240.0130.07019.04
5.4.230.0130.07019.12
5.4.220.0030.08019.26
5.4.210.0100.04719.09
5.4.200.0130.06018.88
5.4.190.0100.05319.05
5.4.180.0130.06319.01
5.4.170.0070.08019.12
5.4.160.0030.04719.03
5.4.150.0100.07019.11
5.4.140.0000.07316.36
5.4.130.0030.03716.42
5.4.120.0070.05016.46
5.4.110.0070.07016.46
5.4.100.0030.04016.45
5.4.90.0030.07716.45
5.4.80.0070.04316.38
5.4.70.0130.06016.42
5.4.60.0100.05316.29
5.4.50.0130.04316.40
5.4.40.0030.05016.59
5.4.30.0000.04016.26
5.4.20.0200.03716.37
5.4.10.0030.08016.30
5.4.00.0030.07015.81
5.3.290.0030.05314.73
5.3.280.0070.07314.65
5.3.270.0000.06714.68
5.3.260.0130.05714.65
5.3.250.0100.07014.64
5.3.240.0100.06714.64
5.3.230.0030.07014.67
5.3.220.0100.04314.63
5.3.210.0030.04014.56
5.3.200.0070.05314.66
5.3.190.0070.05714.41
5.3.180.0070.07314.62
5.3.170.0070.08014.61
5.3.160.0070.08014.58
5.3.150.0070.06714.59
5.3.140.0130.06014.60
5.3.130.0170.07014.54
5.3.120.0100.03314.59
5.3.110.0030.05714.57
5.3.100.0000.05714.09
5.3.90.0030.06314.03
5.3.80.0030.06714.22
5.3.70.0130.06714.07
5.3.60.0100.07314.21
5.3.50.0070.05013.93
5.3.40.0030.06014.01
5.3.30.0030.07013.92
5.3.20.0030.08013.71
5.3.10.0100.05313.67
5.3.00.0100.06713.70
5.2.170.0000.06711.17
5.2.160.0030.05011.16
5.2.150.0070.05710.99
5.2.140.0130.05311.35
5.2.130.0000.04311.14
5.2.120.0030.05710.97
5.2.110.0070.06011.15
5.2.100.0070.03311.32
5.2.90.0000.03711.10
5.2.80.0000.06310.99
5.2.70.0030.04011.09
5.2.60.0030.05011.02
5.2.50.0000.05011.07
5.2.40.0070.05711.00
5.2.30.0100.03310.87
5.2.20.0000.06710.99
5.2.10.0030.03710.91
5.2.00.0030.04010.75
5.1.60.0070.05310.00
5.1.50.0070.05010.00
5.1.40.0070.0439.99
5.1.30.0030.03710.36
5.1.20.0170.05010.43
5.1.10.0030.05710.14
5.1.00.0030.05710.12
5.0.50.0030.0478.63
5.0.40.0070.0438.51
5.0.30.0030.0508.27
5.0.20.0000.0208.15
5.0.10.0000.0238.17
5.0.00.0000.0478.21
4.4.90.0000.0177.66
4.4.80.0030.0377.66
4.4.70.0070.0177.66
4.4.60.0030.0207.66
4.4.50.0000.0237.66
4.4.40.0030.0577.66
4.4.30.0030.0277.66
4.4.20.0070.0337.66
4.4.10.0030.0237.66
4.4.00.0000.0577.66
4.3.110.0030.0337.66
4.3.100.0000.0177.66
4.3.90.0000.0177.66
4.3.80.0000.0337.66
4.3.70.0000.0237.66
4.3.60.0030.0177.66
4.3.50.0000.0237.66
4.3.40.0000.0277.66
4.3.30.0000.0177.66
4.3.20.0000.0207.66
4.3.10.0000.0177.66
4.3.00.0000.0237.66

preferences:
64 ms | 401 KiB | 5 Q