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?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.60.0110.00716.88
8.3.50.0170.00218.45
8.3.40.0090.00618.92
8.3.30.0090.00618.99
8.3.20.0060.00319.03
8.3.10.0040.00420.61
8.3.00.0090.00319.51
8.2.180.0090.00616.88
8.2.170.0130.00322.96
8.2.160.0120.00320.64
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0040.00420.53
8.2.110.0070.00320.98
8.2.100.0080.00417.97
8.2.90.0100.00019.42
8.2.80.0040.00718.05
8.2.70.0060.00318.00
8.2.60.0090.00018.16
8.2.50.0030.00618.07
8.2.40.0000.00818.14
8.2.30.0000.00718.17
8.2.20.0040.00417.81
8.2.10.0040.00417.94
8.2.00.0060.00317.91
8.1.280.0100.01025.92
8.1.270.0000.00824.66
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00622.46
8.1.230.0070.00321.07
8.1.220.0040.00417.91
8.1.210.0040.00418.85
8.1.200.0060.00317.60
8.1.190.0040.00417.52
8.1.180.0040.00418.10
8.1.170.0000.00818.96
8.1.160.0000.00818.94
8.1.150.0000.00818.88
8.1.140.0000.00817.59
8.1.130.0040.00418.02
8.1.120.0000.00917.68
8.1.110.0000.00717.70
8.1.100.0000.00717.68
8.1.90.0040.00417.73
8.1.80.0030.00517.58
8.1.70.0030.00317.69
8.1.60.0040.00417.78
8.1.50.0000.00817.66
8.1.40.0050.00317.73
8.1.30.0000.00817.81
8.1.20.0060.00317.91
8.1.10.0050.00317.70
8.1.00.0000.00817.65
8.0.300.0000.00920.09
8.0.290.0040.00417.00
8.0.280.0030.00318.51
8.0.270.0030.00317.34
8.0.260.0070.00016.94
8.0.250.0040.00417.14
8.0.240.0000.00717.05
8.0.230.0070.00017.20
8.0.220.0000.00717.11
8.0.210.0090.00317.03
8.0.200.0030.00317.19
8.0.190.0000.00817.18
8.0.180.0000.00717.11
8.0.170.0000.00817.11
8.0.160.0050.00317.11
8.0.150.0000.00917.01
8.0.140.0060.00617.02
8.0.130.0000.00613.54
8.0.120.0050.00317.15
8.0.110.0000.00716.94
8.0.100.0030.00417.18
8.0.90.0000.00717.13
8.0.80.0070.01117.09
8.0.70.0080.00017.06
8.0.60.0000.00717.05
8.0.50.0050.00317.01
8.0.30.0110.00816.99
8.0.20.0080.01217.47
8.0.10.0000.00717.28
8.0.00.0130.00516.85
7.4.330.0050.00013.30
7.4.320.0030.00316.99
7.4.300.0070.00017.00
7.4.290.0070.00016.74
7.4.280.0000.01016.93
7.4.270.0060.00316.85
7.4.260.0000.00613.48
7.4.250.0030.00616.93
7.4.240.0000.00716.95
7.4.230.0030.00617.00
7.4.220.0100.01016.80
7.4.210.0050.01016.89
7.4.200.0000.00716.75
7.4.190.0050.00317.03
7.4.160.0100.00716.86
7.4.150.0110.01416.61
7.4.140.0140.00516.79
7.4.130.0090.00916.94
7.4.120.0080.01316.84
7.4.110.0140.00316.79
7.4.100.0100.01316.68
7.4.90.0110.01116.84
7.4.80.0110.00717.01
7.4.70.0150.00316.64
7.4.60.0140.01016.90
7.4.50.0090.00216.62
7.4.40.0090.00616.73
7.4.30.0060.00916.59
7.4.00.0090.00815.05
7.3.330.0030.00313.57
7.3.320.0030.00313.48
7.3.310.0070.00016.32
7.3.300.0000.00716.38
7.3.290.0000.01516.49
7.3.280.0060.01216.49
7.3.270.0090.01516.87
7.3.260.0110.01416.96
7.3.250.0130.00916.66
7.3.240.0130.00316.86
7.3.230.0110.00616.47
7.3.210.0100.00716.52
7.3.200.0160.00419.39
7.3.190.0180.00716.88
7.3.180.0100.00716.82
7.3.170.0130.00316.55
7.3.160.0140.00316.72
7.3.120.0080.00914.86
7.3.110.0060.01015.00
7.3.100.0030.01015.02
7.3.90.0020.01014.90
7.3.80.0060.00414.88
7.3.70.0070.00715.11
7.3.60.0040.00815.11
7.3.50.0080.00615.06
7.3.40.0080.00915.06
7.3.30.0080.00615.09
7.3.20.0100.00616.85
7.3.10.0060.00916.57
7.3.00.0070.00916.83
7.2.330.0140.00416.73
7.2.320.0100.01416.95
7.2.310.0130.01316.74
7.2.300.0160.00016.75
7.2.290.0140.00716.82
7.2.250.0070.01115.20
7.2.240.0080.00915.11
7.2.230.0060.01115.34
7.2.220.0050.00815.25
7.2.210.0040.00815.23
7.2.200.0020.01215.17
7.2.190.0030.01315.38
7.2.180.0150.00015.26
7.2.170.0030.00815.25
7.2.160.0050.00915.21
7.2.150.0050.01017.07
7.2.140.0060.00717.17
7.2.130.0050.01116.98
7.2.120.0120.00516.92
7.2.110.0050.01016.91
7.2.100.0080.00916.88
7.2.90.0100.00716.91
7.2.80.0110.00616.88
7.2.70.0100.00716.77
7.2.60.0070.01116.86
7.2.50.0100.00816.96
7.2.40.0020.01316.82
7.2.30.0080.01017.00
7.2.20.0090.00817.01
7.2.10.0060.01016.88
7.2.00.0080.00817.64
7.1.330.0120.00515.96
7.1.320.0070.00715.91
7.1.310.0050.00816.00
7.1.300.0030.01015.92
7.1.290.0050.01116.13
7.1.280.0080.00615.97
7.1.270.0110.00115.70
7.1.260.0030.01015.89
7.1.250.0030.01116.02
7.1.240.0100.00716.00
7.1.230.0090.00615.89
7.1.220.0070.00416.07
7.1.210.0000.01416.02
7.1.200.0110.00415.83
7.1.190.0060.00815.85
7.1.180.0000.01416.01
7.1.170.0080.00615.89
7.1.160.0000.01716.08
7.1.150.0060.01216.10
7.1.140.0120.00316.08
7.1.130.0030.01215.88
7.1.120.0000.01716.07
7.1.110.0070.00715.73
7.1.100.0090.00417.06
7.1.90.0040.01115.82
7.1.80.0150.00015.85
7.1.70.0010.01016.76
7.1.60.0060.01217.58
7.1.50.0080.01016.64
7.1.40.0030.01016.01
7.1.30.0000.01315.75
7.1.20.0030.01415.89
7.1.10.0000.01415.91
7.1.00.0030.02219.23
7.0.330.0000.01115.54
7.0.320.0080.00015.53
7.0.310.0000.01315.26
7.0.300.0040.00815.44
7.0.290.0120.00315.30
7.0.280.0060.01015.45
7.0.270.0030.00615.35
7.0.260.0040.01115.28
7.0.250.0090.00315.45
7.0.240.0000.01415.60
7.0.230.0000.01415.79
7.0.220.0000.01715.36
7.0.210.0000.01415.34
7.0.200.0060.00415.21
7.0.190.0090.00615.27
7.0.180.0060.00815.71
7.0.170.0060.00315.69
7.0.160.0060.00615.52
7.0.150.0080.00415.48
7.0.140.0020.04318.77
7.0.130.0120.00315.32
7.0.120.0020.04218.79
7.0.110.0080.00415.54
7.0.100.0070.00715.57
7.0.90.0100.00715.41
7.0.80.0070.00415.57
7.0.70.0060.00315.42
7.0.60.0080.04417.77
7.0.50.0120.03116.73
7.0.40.0030.04215.81
7.0.30.0130.03815.75
7.0.20.0090.04215.82
7.0.10.0050.02715.62
7.0.00.0170.02015.79
5.6.400.0110.00314.50
5.6.390.0030.00614.39
5.6.380.0040.01114.18
5.6.370.0100.00714.51
5.6.360.0030.01014.64
5.6.350.0100.00014.30
5.6.340.0040.01214.80
5.6.330.0000.01514.43
5.6.320.0000.01014.72
5.6.310.0000.00914.64
5.6.300.0040.01114.40
5.6.290.0090.00014.33
5.6.280.0070.03717.77
5.6.270.0000.00914.74
5.6.260.0150.00014.65
5.6.250.0070.01014.57
5.6.240.0030.00614.42
5.6.230.0070.00314.54
5.6.220.0040.00714.22
5.6.210.0090.02817.47
5.6.200.0050.02216.31
5.6.190.0070.03516.49
5.6.180.0050.02716.28
5.6.170.0100.02816.43
5.6.160.0070.04516.31
5.6.150.0100.04116.28
5.6.140.0050.02416.19
5.6.130.0020.02816.34
5.6.120.0070.04516.26
5.6.110.0070.02716.26
5.6.100.0060.02616.09
5.6.90.0050.02616.24
5.6.80.0070.04215.84
5.6.70.0020.04315.97
5.6.60.0060.04315.98
5.6.50.0090.04215.86
5.6.40.0000.03515.94
5.6.30.0050.02515.98
5.6.20.0040.03215.95
5.6.10.0040.02416.05
5.6.00.0080.03815.84
5.5.380.0100.00614.29
5.5.370.0060.00314.45
5.5.360.0040.00814.17
5.5.350.0020.04617.50
5.5.340.0020.02916.22
5.5.330.0030.02816.11
5.5.320.0120.02316.01
5.5.310.0080.03216.13
5.5.300.0030.04216.27
5.5.290.0090.04016.24
5.5.280.0030.04516.01
5.5.270.0030.02516.36
5.5.260.0050.02216.23
5.5.250.0110.04016.13
5.5.240.0090.03615.81
5.5.230.0030.03015.91
5.5.220.0060.04315.95
5.5.210.0050.04515.76
5.5.200.0070.03315.87
5.5.190.0080.02315.94
5.5.180.0050.04015.89
5.5.170.0040.00814.09
5.5.160.0070.03215.72
5.5.150.0030.04215.86
5.5.140.0040.02915.66
5.5.130.0070.02815.97
5.5.120.0060.02215.81
5.5.110.0050.02715.67
5.5.100.0120.03715.79
5.5.90.0080.02515.67
5.5.80.0050.02815.85
5.5.70.0080.02315.74
5.5.60.0040.02415.72
5.5.50.0060.03815.68
5.5.40.0060.04115.79
5.5.30.0050.03815.71
5.5.20.0030.03315.66
5.5.10.0060.03415.63
5.5.00.0060.03815.70
5.4.450.0050.04115.28
5.4.440.0000.05015.34
5.4.430.0050.02015.32
5.4.420.0020.03115.21
5.4.410.0050.04315.32
5.4.400.0070.04115.24
5.4.390.0140.03015.07
5.4.380.0070.03515.12
5.4.370.0020.03715.11
5.4.360.0050.03915.16
5.4.350.0100.04015.16
5.4.340.0060.02315.09
5.4.330.0050.00510.95
5.4.320.0070.03414.97
5.4.310.0030.02615.11
5.4.300.0020.04414.96
5.4.290.0130.03014.93
5.4.280.0060.02315.00
5.4.270.0150.02815.02
5.4.260.0070.02315.13
5.4.250.0070.04215.03
5.4.240.0050.02615.11
5.4.230.0000.03315.12
5.4.220.0030.02414.97
5.4.210.0030.02314.98
5.4.200.0050.03015.04
5.4.190.0030.02514.95
5.4.180.0080.03815.02
5.4.170.0030.04714.90
5.4.160.0070.04015.14
5.4.150.0050.02315.20
5.4.140.0020.02613.81
5.4.130.0080.01613.94
5.4.120.0090.03813.69
5.4.110.0080.03613.81
5.4.100.0030.04213.79
5.4.90.0020.03913.84
5.4.80.0030.03713.83
5.4.70.0070.03513.83
5.4.60.0060.03913.72
5.4.50.0080.03613.72
5.4.40.0070.02313.71
5.4.30.0050.04013.63
5.4.20.0060.03813.68
5.4.10.0030.02313.67
5.4.00.0000.04213.41
5.3.290.0000.02312.78
5.3.280.0030.02612.60
5.3.270.0070.02412.64
5.3.260.0050.04012.62
5.3.250.0050.02012.55
5.3.240.0030.02012.60
5.3.230.0000.02512.56
5.3.220.0040.03912.56
5.3.210.0070.04012.48
5.3.200.0060.02112.60
5.3.190.0030.03312.61
5.3.180.0050.03012.62
5.3.170.0110.02712.55
5.3.160.0070.04212.54
5.3.150.0060.03812.67
5.3.140.0060.04012.57
5.3.130.0030.03412.51
5.3.120.0090.03012.58
5.3.110.0060.04112.46
5.3.100.0100.03512.35
5.3.90.0030.03912.36
5.3.80.0070.03612.29
5.3.70.0050.03912.31
5.3.60.0050.02312.38
5.3.50.0050.03912.25
5.3.40.0080.02012.13
5.3.30.0050.03812.28
5.3.20.0000.02812.15
5.3.10.0070.03512.04
5.3.00.0070.02912.07
5.2.170.0000.04011.20
5.2.160.0070.06011.04
5.2.150.0100.05311.15
5.2.140.0070.06011.21
5.2.130.0030.06311.16
5.2.120.0030.03711.16
5.2.110.0070.06011.10
5.2.100.0030.05011.16
5.2.90.0000.04711.16
5.2.80.0030.03711.09
5.2.70.0030.06711.11
5.2.60.0130.05011.07
5.2.50.0070.05711.05
5.2.40.0030.03711.03
5.2.30.0070.06011.02
5.2.20.0000.05011.01
5.2.10.0070.06010.93
5.2.00.0030.04010.68
5.1.60.0000.03310.00
5.1.50.0000.02710.07
5.1.40.0030.0239.90
5.1.30.0030.02310.37
5.1.20.0030.03310.40
5.1.10.0030.02710.07
5.1.00.0030.02710.05
5.0.50.0030.0208.60
5.0.40.0030.0278.26
5.0.30.0070.0238.27
5.0.20.0000.0238.27
5.0.10.0030.0178.25
5.0.00.0070.0338.21
4.4.90.0000.0238.20
4.4.80.0030.0378.20
4.4.70.0000.0378.20
4.4.60.0070.0338.20
4.4.50.0030.0238.20
4.4.40.0000.0278.20
4.4.30.0000.0308.20
4.4.20.0000.0178.20
4.4.10.0030.0138.20
4.4.00.0000.0408.20
4.3.110.0000.0238.20
4.3.100.0000.0178.20
4.3.90.0030.0138.20
4.3.80.0000.0238.20
4.3.70.0030.0138.20
4.3.60.0000.0138.20
4.3.50.0000.0178.20
4.3.40.0000.0238.20
4.3.30.0000.0178.20
4.3.20.0000.0208.20
4.3.10.0000.0178.20
4.3.00.0070.0138.20

preferences:
49.13 ms | 401 KiB | 5 Q