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.60.0090.00918.43
8.3.50.0210.01016.64
8.3.40.0080.00819.00
8.3.30.0190.00318.84
8.3.20.0070.00318.90
8.3.10.0040.00420.83
8.3.00.0060.00317.88
8.2.180.0120.00616.73
8.2.170.0160.00622.96
8.2.160.0130.00622.43
8.2.150.0050.00324.18
8.2.140.0100.01024.66
8.2.130.0040.01226.16
8.2.120.0040.01119.95
8.2.110.0040.00720.35
8.2.100.0040.00818.09
8.2.90.0050.00319.33
8.2.80.0030.00517.97
8.2.70.0030.00617.63
8.2.60.0000.01118.03
8.2.50.0030.00618.07
8.2.40.0080.00018.22
8.2.30.0110.00018.17
8.2.20.0000.00717.91
8.2.10.0000.00817.81
8.2.00.0100.00017.87
8.1.280.0120.00625.92
8.1.270.0040.00423.99
8.1.260.0030.01026.35
8.1.250.0040.00428.09
8.1.240.0030.00622.39
8.1.230.0040.00817.83
8.1.220.0000.00817.74
8.1.210.0030.00518.77
8.1.200.0090.00017.60
8.1.190.0050.00317.79
8.1.180.0040.00418.10
8.1.170.0080.00018.75
8.1.160.0000.00718.93
8.1.150.0000.00818.95
8.1.140.0050.00317.75
8.1.130.0030.00317.91
8.1.120.0040.00417.66
8.1.110.0050.00317.63
8.1.100.0040.00417.61
8.1.90.0040.00417.72
8.1.80.0000.00817.52
8.1.70.0000.00717.59
8.1.60.0100.00317.77
8.1.50.0060.00317.48
8.1.40.0050.00317.73
8.1.30.0040.00417.73
8.1.20.0060.00317.85
8.1.10.0000.00817.73
8.1.00.0040.00417.55
8.0.300.0040.00418.77
8.0.290.0020.00516.88
8.0.280.0040.00418.57
8.0.270.0030.00317.33
8.0.260.0070.00017.04
8.0.250.0030.00517.11
8.0.240.0000.01117.13
8.0.230.0040.00317.04
8.0.220.0050.00317.11
8.0.210.0040.00417.03
8.0.200.0070.00017.15
8.0.190.0000.00717.16
8.0.180.0000.00817.10
8.0.170.0090.00017.13
8.0.160.0070.00016.97
8.0.150.0030.00617.00
8.0.140.0000.01317.08
8.0.130.0030.00313.52
8.0.120.0030.00617.03
8.0.110.0000.00817.04
8.0.100.0100.00017.18
8.0.90.0030.00517.14
8.0.80.0080.00817.20
8.0.70.0040.00416.98
8.0.60.0040.00417.05
8.0.50.0050.00217.15
8.0.30.0100.00917.31
8.0.20.0130.00817.42
8.0.10.0040.00417.10
8.0.00.0080.01216.97
7.4.330.0060.00015.04
7.4.320.0060.00016.84
7.4.300.0000.00616.71
7.4.290.0040.00416.92
7.4.280.0080.00016.73
7.4.270.0030.00316.96
7.4.260.0000.00513.55
7.4.250.0050.00316.79
7.4.240.0000.00816.91
7.4.230.0040.00417.00
7.4.220.0120.01416.95
7.4.210.0110.00516.91
7.4.200.0000.00716.81
7.4.190.0070.00016.66
7.4.160.0130.00316.74
7.4.150.0030.01617.18
7.4.140.0080.01017.39
7.4.130.0140.00716.86
7.4.120.0110.00816.78
7.4.110.0070.01616.56
7.4.100.0180.00416.84
7.4.90.0100.01016.78
7.4.80.0100.00718.80
7.4.70.0090.00816.73
7.4.60.0090.01416.84
7.4.50.0040.00416.51
7.4.40.0030.01022.27
7.4.30.0060.01016.69
7.4.10.0090.01014.94
7.4.00.0100.00515.04
7.3.330.0000.00713.31
7.3.320.0030.00313.32
7.3.310.0030.00316.52
7.3.300.0030.00316.50
7.3.290.0000.01416.52
7.3.280.0060.01216.45
7.3.270.0090.01617.18
7.3.260.0140.00618.24
7.3.250.0070.01216.73
7.3.240.0070.01016.55
7.3.230.0030.01616.85
7.3.210.0060.01216.55
7.3.200.0030.01519.39
7.3.190.0070.01316.78
7.3.180.0000.01716.55
7.3.170.0060.01316.79
7.3.160.0020.01516.54
7.3.130.0110.00714.67
7.3.120.0020.01515.07
7.3.110.0030.01715.07
7.3.100.0060.00914.79
7.3.90.0090.00615.24
7.3.80.0060.00914.95
7.3.70.0070.00714.90
7.3.60.0110.00614.72
7.3.50.0040.00714.89
7.3.40.0100.00014.86
7.3.30.0150.00315.10
7.3.20.0070.00316.84
7.3.10.0100.00416.74
7.3.00.0060.00716.80
7.2.330.0120.00616.87
7.2.320.0120.00617.00
7.2.310.0080.01216.83
7.2.300.0030.01416.75
7.2.290.0150.00316.96
7.2.260.0140.00714.98
7.2.250.0060.01315.33
7.2.240.0100.00315.42
7.2.230.0070.01115.11
7.2.220.0120.00915.41
7.2.210.0000.01515.36
7.2.200.0030.00715.22
7.2.190.0060.00915.28
7.2.180.0000.01915.29
7.2.170.0030.01415.30
7.2.160.0030.01615.32
7.2.150.0070.01117.17
7.2.140.0030.01017.09
7.2.130.0060.00717.08
7.2.120.0100.00617.02
7.2.110.0130.00517.14
7.2.100.0060.01117.03
7.2.90.0090.00816.97
7.2.80.0100.00917.06
7.2.70.0120.00716.93
7.2.60.0090.00516.86
7.2.50.0100.00816.97
7.2.40.0090.01017.11
7.2.30.0080.00717.13
7.2.20.0090.00716.96
7.2.10.0070.00816.91
7.2.00.0070.00617.69
7.1.330.0030.01115.99
7.1.320.0100.01015.82
7.1.310.0060.00915.79
7.1.300.0060.01216.00
7.1.290.0080.00615.78
7.1.280.0000.01915.79
7.1.270.0000.00915.66
7.1.260.0040.01115.96
7.1.250.0070.00915.98
7.1.240.0100.01115.93
7.1.230.0120.00715.92
7.1.220.0080.00715.80
7.1.210.0130.00415.72
7.1.200.0070.01115.82
7.1.190.0090.00915.78
7.1.180.0100.00515.83
7.1.170.0080.01216.05
7.1.160.0100.00915.73
7.1.150.0110.00615.74
7.1.140.0090.00615.92
7.1.130.0110.00615.80
7.1.120.0060.00815.64
7.1.110.0070.00715.90
7.1.100.0020.01016.62
7.1.90.0070.01015.66
7.1.80.0130.00715.90
7.1.70.0090.00716.49
7.1.60.0060.00817.13
7.1.50.0100.00816.22
7.1.40.0070.01015.76
7.1.30.0060.00715.81
7.1.20.0070.00915.88
7.1.10.0050.01115.80
7.1.00.0070.02218.02
7.0.330.0060.00915.38
7.0.320.0060.00715.64
7.0.310.0140.00915.47
7.0.300.0150.00715.37
7.0.290.0030.01415.33
7.0.280.0030.01415.32
7.0.270.0100.00515.35
7.0.260.0060.00815.08
7.0.250.0020.01215.51
7.0.240.0050.00915.41
7.0.230.0090.01115.55
7.0.220.0140.00815.68
7.0.210.0090.00315.68
7.0.200.0030.01015.98
7.0.190.0090.00415.51
7.0.180.0070.01015.46
7.0.170.0140.00515.55
7.0.160.0080.00715.47
7.0.150.0040.00815.41
7.0.140.0090.02717.74
7.0.130.0050.00815.61
7.0.120.0070.01115.55
7.0.110.0110.00715.45
7.0.100.0070.01015.35
7.0.90.0070.00815.39
7.0.80.0070.00715.47
7.0.70.0100.00615.53
7.0.60.0070.02516.86
7.0.50.0080.03116.40
7.0.40.0070.03314.78
7.0.30.0050.03314.93
7.0.20.0040.03114.98
7.0.10.0090.02515.01
7.0.00.0150.02714.94
5.6.400.0040.01114.43
5.6.390.0000.01314.47
5.6.380.0080.00814.24
5.6.370.0020.01114.41
5.6.360.0030.01114.53
5.6.350.0060.00614.64
5.6.340.0100.00614.53
5.6.330.0060.00914.43
5.6.320.0050.01114.39
5.6.310.0070.00714.66
5.6.300.0070.01214.35
5.6.290.0090.00614.39
5.6.280.0050.01014.05
5.6.270.0050.00814.53
5.6.260.0080.01114.21
5.6.250.0040.01114.25
5.6.240.0050.01114.36
5.6.230.0020.01214.48
5.6.220.0040.00914.20
5.6.210.0050.03316.32
5.6.200.0080.02215.65
5.6.190.0090.03015.67
5.6.180.0060.03115.54
5.6.170.0040.02815.66
5.6.160.0120.01915.59
5.6.150.0070.03415.65
5.6.140.0070.01815.66
5.6.130.0060.01815.54
5.6.120.0080.03115.65
5.6.110.0090.03115.66
5.6.100.0060.03615.61
5.6.90.0050.02115.75
5.6.80.0070.01815.36
5.6.70.0040.03415.33
5.6.60.0040.02115.33
5.6.50.0010.02615.31
5.6.40.0100.02215.24
5.6.30.0050.02015.35
5.6.20.0050.02515.30
5.6.10.0070.01915.42
5.6.00.0090.01915.38
5.5.380.0080.00512.72
5.5.370.0060.00812.71
5.5.360.0040.00912.46
5.5.350.0040.03315.29
5.5.340.0030.02814.55
5.5.330.0050.02114.38
5.5.320.0050.03114.46
5.5.310.0020.02214.41
5.5.300.0070.03014.70
5.5.290.0040.02614.52
5.5.280.0070.01614.38
5.5.270.0060.01814.62
5.5.260.0050.01714.42
5.5.250.0030.02114.35
5.5.240.0070.01314.35
5.5.230.0100.02514.22
5.5.220.0030.03514.29
5.5.210.0070.03014.23
5.5.200.0020.03214.21
5.5.190.0100.01614.19
5.5.180.0040.01814.23
5.5.170.0050.00512.56
5.5.160.0040.01814.18
5.5.150.0040.03314.30
5.5.140.0050.02114.31
5.5.130.0040.01814.35
5.5.120.0080.01614.22
5.5.110.0030.02314.19
5.5.100.0080.01314.17
5.5.90.0030.02114.02
5.5.80.0050.02214.04
5.5.70.0010.02914.17
5.5.60.0050.01914.24
5.5.50.0060.01814.16
5.5.40.0060.01914.10
5.5.30.0070.03014.26
5.5.20.0070.02414.23
5.5.10.0050.02114.08
5.5.00.0020.03114.26
5.4.450.0110.02414.25
5.4.440.0080.01614.16
5.4.430.0050.01414.14
5.4.420.0040.02014.20
5.4.410.0060.03014.15
5.4.400.0070.02014.04
5.4.390.0030.03314.04
5.4.380.0040.03113.96
5.4.370.0090.01814.02
5.4.360.0040.02514.04
5.4.350.0060.01814.10
5.4.340.0080.01414.10
5.4.330.0030.00711.57
5.4.320.0040.01714.04
5.4.310.0030.01914.08
5.4.300.0070.01413.94
5.4.290.0040.02313.99
5.4.280.0040.02113.99
5.4.270.0030.03413.95
5.4.260.0020.02013.95
5.4.250.0060.02314.04
5.4.240.0100.01814.05
5.4.230.0070.01313.98
5.4.220.0040.01614.04
5.4.210.0080.01613.98
5.4.200.0030.02514.11
5.4.190.0090.01414.04
5.4.180.0060.01714.02
5.4.170.0050.02414.00
5.4.160.0040.01714.04
5.4.150.0040.01513.99
5.4.140.0070.01713.19
5.4.130.0010.02813.13
5.4.120.0050.02313.09
5.4.110.0030.03213.15
5.4.100.0060.02813.07
5.4.90.0050.02113.15
5.4.80.0040.02213.20
5.4.70.0040.02913.18
5.4.60.0040.02213.13
5.4.50.0020.03113.21
5.4.40.0030.03013.19
5.4.30.0060.01713.23
5.4.20.0060.02613.15
5.4.10.0020.03213.14
5.4.00.0070.02212.98
5.3.290.0040.01712.47
5.3.280.0050.02212.42
5.3.270.0040.02112.41
5.3.260.0050.01412.38
5.3.250.0050.02712.43
5.3.240.0030.02012.33
5.3.230.0020.02912.41
5.3.220.0020.02212.38
5.3.210.0060.03012.37
5.3.200.0110.02512.39
5.3.190.0040.01612.37
5.3.180.0040.01812.34
5.3.170.0040.02812.40
5.3.160.0020.01712.40
5.3.150.0040.02512.38
5.3.140.0110.02312.42
5.3.130.0040.01912.43
5.3.120.0050.02112.37
5.3.110.0020.02712.40
5.3.100.0060.02812.10
5.3.90.0070.02812.22
5.3.80.0050.02712.23
5.3.70.0070.01712.18
5.3.60.0040.02212.19
5.3.50.0050.02912.20
5.3.40.0040.02112.16
5.3.30.0040.01612.09
5.3.20.0060.01512.07
5.3.10.0050.02811.98
5.3.00.0050.02111.95
5.2.170.0050.03310.35
5.2.160.0020.02810.38
5.2.150.0030.02810.38
5.2.140.0080.01910.34
5.2.130.0100.02510.38
5.2.120.0070.01310.48
5.2.110.0050.02610.38
5.2.100.0050.03210.42
5.2.90.0030.01810.40
5.2.80.0030.02210.38
5.2.70.0060.01610.39
5.2.60.0020.01910.46
5.2.50.0020.03610.35
5.2.40.0060.02710.36
5.2.30.0080.03010.33
5.2.20.0090.02510.33
5.2.10.0050.02010.27
5.2.00.0050.03210.18
5.1.60.0050.0289.93
5.1.50.0040.0189.82
5.1.40.0050.0239.84
5.1.30.0040.01810.10
5.1.20.0080.02410.03
5.1.10.0020.0179.97
5.1.00.0050.0119.82
5.0.50.0020.0159.10
5.0.40.0030.0269.14
5.0.30.0040.0328.93
5.0.20.0000.0178.93
5.0.10.0050.0148.91
5.0.00.0000.0388.94
4.4.90.0030.0108.88
4.4.80.0000.0118.88
4.4.70.0020.0148.88
4.4.60.0020.0228.88
4.4.50.0030.0188.88
4.4.40.0030.0278.88
4.4.30.0020.0248.88
4.4.20.0020.0168.88
4.4.10.0020.0218.88
4.4.00.0000.0178.88
4.3.110.0030.0198.88
4.3.100.0070.0128.88
4.3.90.0020.0208.88
4.3.80.0000.0328.88
4.3.70.0000.0228.88
4.3.60.0020.0228.88
4.3.50.0030.0108.88
4.3.40.0000.0228.88
4.3.30.0030.0088.88
4.3.20.0030.0178.88
4.3.10.0020.0188.88
4.3.00.0030.0198.88

preferences:
43.47 ms | 401 KiB | 5 Q