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$2", $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?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.01318.56
8.3.50.0150.00816.80
8.3.40.0110.00418.96
8.3.30.0090.00918.82
8.3.20.0030.00618.94
8.3.10.0080.00020.73
8.3.00.0050.00317.63
8.2.180.0090.00616.47
8.2.170.0110.00322.96
8.2.160.0070.00722.14
8.2.150.0090.00024.18
8.2.140.0120.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00420.07
8.2.110.0070.01020.35
8.2.100.0080.00317.97
8.2.90.0000.00819.36
8.2.80.0080.00017.97
8.2.70.0060.00317.75
8.2.60.0060.00317.80
8.2.50.0040.00418.07
8.2.40.0000.00918.03
8.2.30.0040.00418.13
8.2.20.0000.00818.02
8.2.10.0060.00317.94
8.2.00.0000.00917.80
8.1.280.0030.01325.92
8.1.270.0120.00623.99
8.1.260.0070.01126.35
8.1.250.0120.00628.09
8.1.240.0000.00922.05
8.1.230.0080.00317.64
8.1.220.0050.00317.74
8.1.210.0030.00618.77
8.1.200.0030.00617.73
8.1.190.0000.00817.65
8.1.180.0050.00318.10
8.1.170.0040.00418.96
8.1.160.0040.00419.01
8.1.150.0030.00618.80
8.1.140.0050.00317.70
8.1.130.0030.00317.82
8.1.120.0000.00717.61
8.1.110.0040.00417.59
8.1.100.0070.00017.59
8.1.90.0040.00417.69
8.1.80.0040.00417.63
8.1.70.0070.00017.65
8.1.60.0080.00017.80
8.1.50.0060.00317.61
8.1.40.0030.00617.69
8.1.30.0040.00417.86
8.1.20.0000.00917.74
8.1.10.0040.00417.65
8.1.00.0090.00017.47
8.0.300.0080.00018.77
8.0.290.0000.00817.00
8.0.280.0070.00018.50
8.0.270.0070.00017.31
8.0.260.0030.00316.95
8.0.250.0000.00917.03
8.0.240.0060.00617.19
8.0.230.0030.00616.98
8.0.220.0000.00717.22
8.0.210.0030.00517.00
8.0.200.0040.00417.20
8.0.190.0000.00817.16
8.0.180.0050.00217.07
8.0.170.0090.00017.16
8.0.160.0040.00417.06
8.0.150.0050.00316.92
8.0.140.0070.00617.04
8.0.130.0050.00013.59
8.0.120.0000.00717.07
8.0.110.0040.00417.02
8.0.100.0070.00017.13
8.0.90.0040.00417.01
8.0.80.0040.01217.02
8.0.70.0050.00317.05
8.0.60.0000.00817.01
8.0.50.0040.00417.10
8.0.30.0110.00817.06
8.0.20.0100.01017.24
8.0.10.0030.00517.10
8.0.00.0110.00917.10
7.4.330.0050.00014.93
7.4.320.0000.00616.74
7.4.300.0030.00316.91
7.4.290.0030.00316.84
7.4.280.0000.00816.86
7.4.270.0080.00016.90
7.4.260.0030.00313.48
7.4.250.0000.00816.86
7.4.240.0030.00516.78
7.4.230.0080.00016.73
7.4.220.0110.00716.85
7.4.210.0040.01316.87
7.4.200.0030.00316.65
7.4.190.0000.00816.89
7.4.160.0030.01716.70
7.4.150.0120.00617.18
7.4.140.0120.00917.29
7.4.130.0130.00616.63
7.4.120.0100.01116.81
7.4.110.0090.00916.88
7.4.100.0150.00316.78
7.4.90.0090.00916.91
7.4.80.0070.01018.80
7.4.70.0110.00616.61
7.4.60.0090.01216.78
7.4.50.0040.00416.62
7.4.40.0040.01122.27
7.4.30.0120.00416.77
7.4.00.0030.00915.38
7.3.330.0030.00313.32
7.3.320.0030.00313.40
7.3.310.0050.00216.29
7.3.300.0040.00416.42
7.3.290.0080.00616.54
7.3.280.0090.00816.46
7.3.270.0080.00917.18
7.3.260.0100.00718.24
7.3.250.0100.00716.73
7.3.240.0110.00616.48
7.3.230.0170.00016.49
7.3.210.0160.00316.50
7.3.200.0100.01019.39
7.3.190.0120.00616.67
7.3.180.0100.00716.79
7.3.170.0140.00316.90
7.3.160.0100.00716.54
7.3.120.0000.01614.88
7.2.330.0000.01716.80
7.2.320.0100.00716.93
7.2.310.0090.01016.91
7.2.300.0060.01217.00
7.2.290.0100.00916.81
7.2.00.0110.00719.42
7.1.200.0070.00715.95
7.1.100.0090.00618.52
7.1.70.0000.00817.55
7.1.60.0190.00619.40
7.1.50.0100.00716.97
7.1.00.0130.06022.47
7.0.200.0040.00416.79
7.0.140.0070.07022.21
7.0.60.0000.08719.95
7.0.50.0030.04017.88
7.0.40.0000.05020.15
7.0.30.0030.06020.13
7.0.20.0130.04320.32
7.0.10.0000.05020.13
7.0.00.0100.06320.28
5.6.280.0070.07021.09
5.6.210.0030.07320.50
5.6.200.0000.04718.29
5.6.190.0030.08320.77
5.6.180.0070.04720.73
5.6.170.0000.05720.51
5.6.160.0100.08020.57
5.6.150.0000.09320.52
5.6.140.0000.07320.23
5.6.130.0030.05020.16
5.6.120.0070.05020.19
5.6.110.0030.04720.31
5.6.100.0100.04020.34
5.6.90.0100.07720.31
5.6.80.0130.08319.57
5.6.70.0000.08719.61
5.6.60.0030.08319.57
5.6.50.0070.05019.89
5.6.40.0100.08019.85
5.6.30.0100.08319.69
5.6.20.0030.06319.59
5.6.10.0000.09019.52
5.6.00.0000.08719.54
5.5.350.0170.06720.44
5.5.340.0070.07017.98
5.5.330.0130.05320.27
5.5.320.0030.07720.46
5.5.310.0070.05720.29
5.5.300.0100.06720.12
5.5.290.0170.05720.13
5.5.280.0070.04319.99
5.5.270.0070.04320.23
5.5.260.0100.08020.30
5.5.250.0070.06720.10
5.5.240.0130.05019.36
5.5.230.0030.08319.35
5.5.220.0100.06719.51
5.5.210.0070.04019.37
5.5.200.0070.08719.65
5.5.190.0030.05719.49
5.5.180.0070.06319.49
5.5.160.0100.07719.34
5.5.150.0000.04719.68
5.5.140.0030.04719.35
5.5.130.0130.08019.55
5.5.120.0030.06719.46
5.5.110.0130.07019.54
5.5.100.0070.05319.49
5.5.90.0100.07719.45
5.5.80.0030.04319.22
5.5.70.0100.07719.38
5.5.60.0070.07719.24
5.5.50.0070.06719.36
5.5.40.0100.06719.22
5.5.30.0030.04719.38
5.5.20.0000.07319.27
5.5.10.0100.04319.37
5.5.00.0000.09319.36
5.4.450.0100.07719.26
5.4.440.0070.06719.57
5.4.430.0000.04719.40
5.4.420.0070.05019.56
5.4.410.0130.07319.36
5.4.400.0100.06718.87
5.4.390.0070.07718.85
5.4.380.0070.06318.85
5.4.370.0030.06719.25
5.4.360.0100.06719.24
5.4.350.0130.07019.12
5.4.340.0130.04718.86
5.4.320.0100.07719.14
5.4.310.0100.07318.87
5.4.300.0000.04318.98
5.4.290.0070.04019.25
5.4.280.0000.06318.83
5.4.270.0030.06718.98
5.4.260.0030.08018.92
5.4.250.0100.07319.18
5.4.240.0100.07018.85
5.4.230.0100.07318.84
5.4.220.0070.07718.85
5.4.210.0100.06319.14
5.4.200.0070.04018.93
5.4.190.0070.07319.24
5.4.180.0070.04718.84
5.4.170.0070.05019.14
5.4.160.0100.05718.96
5.4.150.0000.07718.90
5.4.140.0100.07016.50
5.4.130.0100.05016.50
5.4.120.0030.04016.43
5.4.110.0030.07016.49
5.4.100.0100.07016.47
5.4.90.0030.04316.48
5.4.80.0100.04716.46
5.4.70.0030.04016.57
5.4.60.0030.04316.36
5.4.50.0070.07716.64
5.4.40.0100.06716.47
5.4.30.0070.06016.55
5.4.20.0030.08016.38
5.4.10.0100.06716.46
5.4.00.0170.06715.76
5.3.290.0100.07714.73
5.3.280.0100.06714.62
5.3.270.0030.04014.66
5.3.260.0070.05314.76
5.3.250.0130.07014.60
5.3.240.0100.07714.66
5.3.230.0100.04014.62
5.3.220.0070.03314.72
5.3.210.0070.05314.63
5.3.200.0070.07714.60
5.3.190.0030.08314.59
5.3.180.0100.07314.57
5.3.170.0070.06714.73
5.3.160.0030.04014.61
5.3.150.0030.07314.56
5.3.140.0070.06714.58
5.3.130.0030.07014.56
5.3.120.0100.06314.54
5.3.110.0100.04714.55
5.3.100.0030.05314.09
5.3.90.0070.03314.07
5.3.80.0070.04314.16
5.3.70.0070.03314.02
5.3.60.0030.04014.07
5.3.50.0130.02713.96
5.3.40.0000.04013.99
5.3.30.0030.03713.91
5.3.20.0030.03713.85
5.3.10.0030.03313.58
5.3.00.0000.03713.68
5.2.170.0000.03311.14
5.2.160.0000.03011.11
5.2.150.0030.02711.24
5.2.140.0000.03011.09
5.2.130.0070.02310.99
5.2.120.0030.02711.04
5.2.110.0000.03011.11
5.2.100.0000.03011.15
5.2.90.0000.03011.25
5.2.80.0000.03011.15
5.2.70.0000.03011.06
5.2.60.0070.02311.05
5.2.50.0030.03011.07
5.2.40.0100.02311.05
5.2.30.0030.02710.98
5.2.20.0000.03011.00
5.2.10.0030.02710.93
5.2.00.0100.02310.77
5.1.60.0030.02310.06
5.1.50.0030.0239.98
5.1.40.0000.02310.04
5.1.30.0000.02710.48
5.1.20.0030.02310.35
5.1.10.0000.02710.13
5.1.00.0030.02310.14
5.0.50.0000.0208.47
5.0.40.0070.0138.46
5.0.30.0030.0308.23
5.0.20.0030.0238.36
5.0.10.0000.0208.23
5.0.00.0030.0278.16
4.4.90.0070.0107.03
4.4.80.0000.0177.03
4.4.70.0000.0177.03
4.4.60.0070.0107.03
4.4.50.0030.0137.03
4.4.40.0000.0277.03
4.4.30.0000.0177.03
4.4.20.0000.0177.03
4.4.10.0070.0107.03
4.4.00.0000.0237.03
4.3.110.0000.0177.03
4.3.100.0000.0307.03
4.3.90.0000.0137.03
4.3.80.0030.0207.03
4.3.70.0000.0177.03
4.3.60.0000.0177.03
4.3.50.0000.0177.03
4.3.40.0030.0237.03
4.3.30.0000.0177.03
4.3.20.0000.0177.03
4.3.10.0000.0177.03
4.3.00.0000.0137.03

preferences:
41.04 ms | 401 KiB | 5 Q