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/*"). 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.40.0040.01519.09
8.3.30.0110.00418.94
8.3.20.0040.00419.00
8.3.10.0050.00320.78
8.3.00.0040.00419.50
8.2.170.0120.00322.96
8.2.160.0100.00321.18
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00020.57
8.2.110.0080.00019.44
8.2.100.0110.00018.16
8.2.90.0060.00319.64
8.2.80.0000.00819.38
8.2.70.0030.00718.00
8.2.60.0040.00418.05
8.2.50.0050.00518.07
8.2.40.0050.00318.03
8.2.30.0040.00418.32
8.2.20.0050.00317.97
8.2.10.0070.00017.95
8.2.00.0040.00417.98
8.1.270.0040.00424.66
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0030.00623.77
8.1.230.0040.00821.01
8.1.220.0040.00417.91
8.1.210.0060.00319.03
8.1.200.0040.00417.47
8.1.190.0000.00817.65
8.1.180.0000.00818.10
8.1.170.0040.00418.88
8.1.160.0080.00019.07
8.1.150.0040.00418.88
8.1.140.0040.00417.84
8.1.130.0030.00317.98
8.1.120.0030.00617.63
8.1.110.0040.00417.67
8.1.100.0080.00017.57
8.1.90.0040.00417.57
8.1.80.0070.00017.73
8.1.70.0000.00717.64
8.1.60.0040.00417.73
8.1.50.0050.00317.58
8.1.40.0080.00017.82
8.1.30.0060.00317.73
8.1.20.0040.00417.72
8.1.10.0080.00017.71
8.1.00.0050.00317.65
8.0.300.0040.00420.06
8.0.290.0040.00417.00
8.0.280.0030.00318.47
8.0.270.0000.00717.29
8.0.260.0000.00817.05
8.0.250.0000.00817.20
8.0.240.0000.00717.18
8.0.230.0030.00317.07
8.0.220.0000.00717.20
8.0.210.0060.00317.13
8.0.200.0030.00317.07
8.0.190.0060.00317.12
8.0.180.0000.00817.16
8.0.170.0070.00317.03
8.0.160.0000.00717.11
8.0.150.0030.00617.02
8.0.140.0120.00017.07
8.0.130.0030.00313.62
8.0.120.0030.00617.17
8.0.110.0070.00017.23
8.0.100.0060.00317.20
8.0.90.0050.00317.07
8.0.80.0110.00417.20
8.0.70.0030.00517.17
8.0.60.0040.00417.22
8.0.50.0000.00817.10
8.0.30.0090.01617.35
8.0.20.0100.01017.40
8.0.10.0000.00717.21
8.0.00.0060.01316.94
7.4.330.0050.00013.34
7.4.320.0000.00716.87
7.4.300.0030.00316.95
7.4.290.0030.00316.96
7.4.280.0060.00316.96
7.4.270.0030.00516.97
7.4.260.0000.00513.74
7.4.250.0060.00316.93
7.4.240.0070.00016.81
7.4.230.0050.00316.97
7.4.220.0160.00316.71
7.4.210.0090.00816.93
7.4.200.0000.00716.61
7.4.190.0030.00516.99
7.4.160.0040.01216.73
7.4.150.0140.00516.84
7.4.140.0120.00916.87
7.4.130.0050.01216.72
7.4.120.0080.01016.86
7.4.110.0100.00716.81
7.4.100.0060.01216.74
7.4.90.0130.00516.85
7.4.80.0070.01016.77
7.4.70.0080.00816.78
7.4.60.0000.01716.62
7.4.50.0070.01016.50
7.4.40.0070.01016.77
7.4.30.0120.00616.61
7.4.00.0040.01115.05
7.3.330.0030.00413.54
7.3.320.0030.00313.33
7.3.310.0040.00416.55
7.3.300.0040.00416.49
7.3.290.0140.00716.50
7.3.280.0100.00616.49
7.3.270.0050.01516.59
7.3.260.0140.00516.53
7.3.250.0140.00616.83
7.3.240.0120.00916.90
7.3.230.0060.01216.87
7.3.210.0090.00916.89
7.3.200.0040.01419.39
7.3.190.0090.00916.57
7.3.180.0110.00516.45
7.3.170.0150.00616.77
7.3.160.0110.00716.74
7.3.120.0060.00315.03
7.2.330.0090.00916.82
7.2.320.0060.01616.98
7.2.310.0070.01716.77
7.2.300.0050.01116.90
7.2.290.0060.01216.94
7.2.00.0040.00819.88
7.1.100.0040.00718.57
7.1.70.0030.00917.30
7.1.60.0030.01417.59
7.1.50.0240.00734.73
7.1.00.0000.03722.37
7.0.200.0170.00017.02
7.0.140.0070.07022.00
7.0.120.0030.06722.13
7.0.60.0070.08020.01
7.0.50.0070.05317.89
7.0.40.0030.09020.05
7.0.30.0170.04320.27
7.0.20.0270.09020.21
7.0.10.0170.05020.27
7.0.00.0070.04020.17
5.6.280.0070.07021.10
5.6.210.0100.07720.48
5.6.200.0100.06718.22
5.6.190.0100.06320.33
5.6.180.0170.04320.46
5.6.170.0570.06320.56
5.6.160.0030.05320.45
5.6.150.0070.07318.12
5.6.140.0030.04018.18
5.6.130.0070.08018.28
5.6.120.0070.05720.99
5.6.110.0130.08020.99
5.6.100.0070.08021.12
5.6.90.0170.06021.13
5.6.80.0070.05020.43
5.6.70.0330.06720.38
5.5.350.0300.07320.44
5.5.340.0030.07318.08
5.5.330.0030.06020.47
5.5.320.0200.05020.41
5.5.310.0330.07320.27
5.5.300.0100.03717.97
5.5.290.0030.04317.97
5.5.280.0030.06020.97
5.5.270.0030.05020.80
5.5.260.0000.07320.77
5.5.250.0130.06020.48
5.5.240.0170.06020.28
5.4.450.0330.06719.55
5.4.440.0130.05319.18
5.4.430.0130.04719.45
5.4.420.0270.06719.31
5.4.410.0270.07319.44
5.4.400.0300.06019.06
5.4.390.0270.07019.25
5.4.380.0330.03719.11
5.4.370.0070.07719.09
5.4.360.0070.07318.99
5.4.350.0170.07719.13
5.4.340.0070.07719.15
5.4.320.0000.05719.32
5.4.310.0000.05319.31
5.4.300.0030.07719.31
5.4.290.0000.07719.21
5.4.280.0100.07019.22
5.4.270.0030.05319.10
5.4.260.0130.07019.24
5.4.250.0070.07319.21
5.4.240.0030.07319.13
5.4.230.0030.04719.13
5.4.220.0130.06019.05
5.4.210.0070.04718.85
5.4.200.0030.04719.21
5.4.190.0070.05018.84
5.4.180.0030.03719.30
5.4.170.0000.06718.84
5.4.160.0130.06019.13
5.4.150.0030.05319.06
5.4.140.0000.04016.36
5.4.130.0000.03716.53
5.4.120.0030.06316.40
5.4.110.0100.06016.61
5.4.100.0000.07716.47
5.4.90.0000.07316.50
5.4.80.0000.07316.56
5.4.70.0000.07716.22
5.4.60.0000.05016.54
5.4.50.0100.06316.51
5.4.40.0000.04716.25
5.4.30.0070.07016.42
5.4.20.0000.04716.53
5.4.10.0000.07316.42
5.4.00.0030.07715.90
5.3.290.0070.05314.57
5.3.280.0000.07714.51
5.3.270.0030.08014.76
5.3.260.0000.05714.52
5.3.250.0100.07314.68
5.3.240.0000.04014.63
5.3.230.0070.07014.52
5.3.220.0000.07314.47
5.3.210.0000.07314.57
5.3.200.0000.05314.50
5.3.190.0070.08014.49
5.3.180.0130.06314.68
5.3.170.0070.05714.53
5.3.160.0030.07014.68
5.3.150.0030.04014.57
5.3.140.0000.05314.46
5.3.130.0030.04014.77
5.3.120.0030.07314.77
5.3.110.0030.05014.54
5.3.100.0030.07314.04
5.3.90.0030.07714.07
5.3.80.0070.07313.95
5.3.70.0000.06713.93
5.3.60.0030.06314.01
5.3.50.0000.07313.88
5.3.40.0030.05013.92
5.3.30.0000.06313.88
5.3.20.0100.06313.60
5.3.10.0000.05013.57
5.3.00.0000.07313.57
5.2.170.0000.06712.15
5.2.160.0000.07012.15
5.2.150.0000.05012.15
5.2.140.0000.05012.15
5.2.130.0000.05712.15
5.2.120.0030.05012.15
5.2.110.0030.04712.15
5.2.100.0070.03712.15
5.2.90.0000.03312.15
5.2.80.0000.06312.15
5.2.70.0030.05012.15
5.2.60.0030.06012.15
5.2.50.0030.04712.15
5.2.40.0070.03012.15
5.2.30.0000.06312.15
5.2.20.0070.02712.15
5.2.10.0030.05712.15
5.2.00.0070.06012.15
5.1.60.0030.05312.15
5.1.50.0030.03712.15
5.1.40.0070.02312.15
5.1.30.0000.05712.15
5.1.20.0070.03312.15
5.1.10.0000.03312.15
5.1.00.0000.03012.15
5.0.50.0030.04712.15
5.0.40.0070.03712.15
5.0.30.0070.06312.15
5.0.20.0000.02312.15
5.0.10.0000.03312.15
5.0.00.0000.04312.15
4.4.90.0030.03712.15
4.4.80.0030.02012.15
4.4.70.0000.03012.15
4.4.60.0000.03012.15
4.4.50.0030.03312.15
4.4.40.0000.05712.15
4.4.30.0000.03712.15
4.4.20.0000.03012.15
4.4.10.0030.03712.15
4.4.00.0000.05312.15
4.3.110.0000.02712.15
4.3.100.0000.03712.15
4.3.90.0030.03012.15
4.3.80.0030.04712.15
4.3.70.0100.02712.15
4.3.60.0000.01712.15
4.3.50.0000.04012.15
4.3.40.0000.04312.15
4.3.30.0030.03712.15
4.3.20.0000.03712.15
4.3.10.0030.02712.15
4.3.00.0030.02712.15

preferences:
53.58 ms | 400 KiB | 5 Q