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$2$3", $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.60.0070.01116.75
8.3.50.0140.00717.84
8.3.40.0090.00618.77
8.3.30.0070.00718.92
8.3.20.0040.01219.04
8.3.10.0090.00020.61
8.3.00.0030.00619.50
8.2.180.0160.00317.00
8.2.170.0120.00422.96
8.2.160.0070.00720.60
8.2.150.0120.00324.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00021.02
8.2.110.0070.00419.44
8.2.100.0000.01218.16
8.2.90.0040.00419.30
8.2.80.0040.00417.97
8.2.70.0040.00417.88
8.2.60.0000.00818.18
8.2.50.0060.00318.07
8.2.40.0060.00318.28
8.2.30.0030.00519.67
8.2.20.0030.00518.02
8.2.10.0000.00817.87
8.2.00.0050.00317.94
8.1.280.0090.00625.92
8.1.270.0000.00824.66
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00620.96
8.1.230.0080.00321.02
8.1.220.0030.00618.77
8.1.210.0040.00419.13
8.1.200.0070.00317.47
8.1.190.0080.00017.78
8.1.180.0040.00918.10
8.1.170.0060.00318.92
8.1.160.0080.00019.12
8.1.150.0040.00418.92
8.1.140.0030.00517.77
8.1.130.0030.00318.00
8.1.120.0080.00017.59
8.1.110.0000.00817.73
8.1.100.0040.00417.68
8.1.90.0070.00017.69
8.1.80.0050.00317.68
8.1.70.0000.00717.66
8.1.60.0040.00417.70
8.1.50.0040.00417.73
8.1.40.0060.00317.79
8.1.30.0030.00517.89
8.1.20.0040.00417.93
8.1.10.0000.00917.74
8.1.00.0000.00817.57
8.0.300.0040.00419.95
8.0.290.0040.00417.30
8.0.280.0040.00418.49
8.0.270.0000.00717.05
8.0.260.0070.00017.05
8.0.250.0040.00417.19
8.0.240.0040.00417.18
8.0.230.0070.00017.18
8.0.220.0030.00317.18
8.0.210.0080.00017.18
8.0.200.0070.00017.05
8.0.190.0040.00417.23
8.0.180.0070.00017.15
8.0.170.0000.00917.02
8.0.160.0070.00017.08
8.0.150.0060.00317.06
8.0.140.0030.00717.01
8.0.130.0030.00313.55
8.0.120.0060.00317.22
8.0.110.0040.00417.09
8.0.100.0070.00017.05
8.0.90.0040.00417.06
8.0.80.0090.00617.11
8.0.70.0000.00817.05
8.0.60.0000.00817.05
8.0.50.0030.00617.00
8.0.30.0110.00917.28
8.0.20.0140.01117.22
8.0.10.0000.00817.37
8.0.00.0130.01017.07
7.4.330.0030.00313.40
7.4.320.0030.00316.78
7.4.300.0050.00316.88
7.4.290.0040.00416.84
7.4.280.0040.00416.96
7.4.270.0030.00516.95
7.4.260.0070.00013.73
7.4.250.0040.00416.91
7.4.240.0040.00416.87
7.4.230.0030.00516.86
7.4.220.0030.01716.75
7.4.210.0120.00716.98
7.4.200.0000.00817.04
7.4.190.0030.00517.06
7.4.160.0150.00317.04
7.4.150.0110.00816.90
7.4.140.0160.00316.75
7.4.130.0080.01016.81
7.4.120.0050.01216.78
7.4.110.0080.00816.68
7.4.100.0070.01116.82
7.4.90.0180.00616.69
7.4.80.0070.01419.39
7.4.70.0120.00616.88
7.4.60.0080.01316.73
7.4.50.0000.01816.74
7.4.40.0070.00716.62
7.4.30.0130.00316.96
7.4.10.0090.00915.20
7.4.00.0070.01115.19
7.3.330.0030.00313.49
7.3.320.0080.00013.46
7.3.310.0000.00716.42
7.3.300.0000.00716.36
7.3.290.0090.00916.52
7.3.280.0110.00816.51
7.3.270.0160.00316.92
7.3.260.0140.01016.65
7.3.250.0120.00716.53
7.3.240.0150.00316.96
7.3.230.0150.00316.90
7.3.210.0070.01016.76
7.3.200.0030.02016.99
7.3.190.0130.00616.80
7.3.180.0030.01316.56
7.3.170.0120.00616.89
7.3.160.0100.01016.77
7.3.130.0110.00615.09
7.3.120.0060.01115.28
7.3.110.0070.01115.13
7.3.100.0050.01115.08
7.3.90.0060.00915.03
7.3.80.0030.01215.06
7.3.70.0050.00615.00
7.3.60.0060.00614.93
7.3.50.0060.00715.15
7.3.40.0030.00914.98
7.3.30.0080.00414.97
7.3.20.0060.00816.88
7.3.10.0060.00716.76
7.3.00.0050.00816.69
7.2.330.0030.01716.98
7.2.320.0070.01117.03
7.2.310.0080.01116.91
7.2.300.0090.00916.82
7.2.290.0140.00316.81
7.2.260.0050.01215.08
7.2.250.0070.01115.14
7.2.240.0080.00915.16
7.2.230.0040.00915.26
7.2.220.0070.00915.30
7.2.210.0060.00915.16
7.2.200.0060.01015.10
7.2.190.0060.00715.24
7.2.180.0070.00615.22
7.2.170.0050.00815.12
7.2.160.0080.00615.20
7.2.150.0070.00317.00
7.2.140.0060.00817.07
7.2.130.0050.00717.06
7.2.120.0040.01217.13
7.2.110.0070.00817.05
7.2.100.0030.01116.99
7.2.90.0020.01216.97
7.2.80.0070.00716.94
7.2.70.0100.00517.10
7.2.60.0070.00517.04
7.2.50.0050.00917.12
7.2.40.0060.00817.05
7.2.30.0040.01017.15
7.2.20.0060.00717.10
7.2.10.0040.00817.06
7.2.00.0070.00716.89
7.1.330.0080.00816.02
7.1.320.0060.00715.89
7.1.310.0060.00816.10
7.1.300.0040.00715.95
7.1.290.0060.00715.94
7.1.280.0040.00915.92
7.1.270.0050.00716.03
7.1.260.0040.01015.96
7.1.250.0030.00815.85
7.1.240.0050.00515.90
7.1.230.0030.00915.98
7.1.220.0040.00615.83
7.1.210.0070.00715.89
7.1.200.0050.00716.03
7.1.190.0060.00715.99
7.1.180.0050.00916.05
7.1.170.0050.00915.87
7.1.160.0030.01015.98
7.1.150.0060.00816.01
7.1.140.0050.00715.84
7.1.130.0050.00615.95
7.1.120.0070.00616.02
7.1.110.0050.00515.93
7.1.100.0050.00715.84
7.1.90.0060.00815.92
7.1.80.0060.00715.87
7.1.70.0060.00616.24
7.1.60.0090.00516.66
7.1.50.0080.00716.20
7.1.40.0060.00815.92
7.1.30.0070.00515.81
7.1.20.0050.00815.89
7.1.10.0060.00915.88
7.1.00.0050.01517.25
7.0.330.0060.00515.52
7.0.320.0020.01115.55
7.0.310.0030.00615.61
7.0.300.0080.00515.43
7.0.290.0040.00815.49
7.0.280.0040.00815.64
7.0.270.0040.00815.47
7.0.260.0060.00615.40
7.0.250.0080.00715.49
7.0.240.0060.00615.55
7.0.230.0070.00415.52
7.0.220.0030.00915.45
7.0.210.0040.00915.54
7.0.200.0080.00915.78
7.0.190.0040.01015.50
7.0.180.0070.00515.45
7.0.170.0040.00715.60
7.0.160.0020.01115.45
7.0.150.0060.00715.49
7.0.140.0040.02116.82
7.0.130.0080.00515.43
7.0.120.0050.02016.89
7.0.110.0040.00915.47
7.0.100.0070.00715.46
7.0.90.0040.00715.52
7.0.80.0050.00715.48
7.0.70.0060.00615.53
7.0.60.0030.01616.32
7.0.50.0040.02416.06
7.0.40.0060.01614.52
7.0.30.0050.01614.53
7.0.20.0060.01914.48
7.0.10.0040.01714.46
7.0.00.0070.01114.56
5.6.400.0050.00814.54
5.6.390.0040.00814.59
5.6.380.0050.00814.36
5.6.370.0060.00814.50
5.6.360.0050.00914.44
5.6.350.0030.00814.14
5.6.340.0080.00614.50
5.6.330.0040.00914.50
5.6.320.0050.00714.44
5.6.310.0070.00814.58
5.6.300.0070.00614.33
5.6.290.0050.00614.54
5.6.280.0040.02115.82
5.6.270.0040.01114.52
5.6.260.0040.00814.31
5.6.250.0060.00614.31
5.6.240.0040.00914.32
5.6.230.0030.00914.43
5.6.220.0050.00914.45
5.6.210.0050.02315.62
5.6.200.0070.01415.12
5.6.190.0070.02115.16
5.6.180.0050.02215.22
5.6.170.0060.01715.20
5.6.160.0040.01615.19
5.6.150.0040.01715.10
5.6.140.0020.01715.10
5.6.130.0050.02315.15
5.6.120.0060.01915.28
5.6.110.0090.01215.18
5.6.100.0060.01415.22
5.6.90.0070.01615.14
5.6.80.0050.01514.88
5.6.70.0050.02314.94
5.6.60.0060.01415.02
5.6.50.0060.01214.88
5.6.40.0060.01414.97
5.6.30.0040.01514.95
5.6.20.0050.01614.89
5.6.10.0050.02215.06
5.6.00.0060.01314.97
5.5.380.0020.00914.25
5.5.370.0080.00314.11
5.5.360.0100.00614.35
5.5.350.0110.02115.65
5.5.340.0050.01515.05
5.5.330.0040.01815.04
5.5.320.0050.01515.11
5.5.310.0050.01715.03
5.5.300.0060.02315.01
5.5.290.0080.02215.07
5.5.280.0030.02214.94
5.5.270.0030.02414.97
5.5.260.0050.01314.98
5.5.250.0050.01314.98
5.5.240.0040.01414.87
5.5.230.0060.01714.83
5.5.220.0060.01314.82
5.5.210.0080.01414.84
5.5.200.0060.01414.92
5.5.190.0020.01614.96
5.5.180.0050.01514.96
5.5.170.0070.00614.20
5.5.160.0040.02014.91
5.5.150.0030.01814.87
5.5.140.0040.01614.91
5.5.130.0060.01414.88
5.5.120.0060.01614.78
5.5.110.0060.01614.91
5.5.100.0060.02114.87
5.5.90.0040.02214.84
5.5.80.0050.02214.91
5.5.70.0070.02014.79
5.5.60.0050.02014.86
5.5.50.0060.02114.80
5.5.40.0040.02014.84
5.5.30.0070.01214.74
5.5.20.0040.02114.80
5.5.10.0090.01814.83
5.5.00.0060.02314.89
5.4.450.0020.01913.47
5.4.440.0040.01813.43
5.4.430.0050.01313.49
5.4.420.0050.01213.42
5.4.410.0010.01713.52
5.4.400.0050.02013.32
5.4.390.0060.01213.21
5.4.380.0050.01113.30
5.4.370.0020.02213.37
5.4.360.0040.01513.33
5.4.350.0060.01813.23
5.4.340.0050.01313.38
5.4.330.0050.00411.76
5.4.320.0050.01213.34
5.4.310.0050.01213.30
5.4.300.0040.01513.34
5.4.290.0030.02213.32
5.4.280.0030.02213.38
5.4.270.0070.01913.21
5.4.260.0070.01713.36
5.4.250.0050.01313.33
5.4.240.0050.01813.28
5.4.230.0060.01813.29
5.4.220.0040.01813.31
5.4.210.0050.01713.19
5.4.200.0020.02213.33
5.4.190.0030.02013.34
5.4.180.0060.01813.35
5.4.170.0050.02113.29
5.4.160.0080.02013.30
5.4.150.0060.01813.30
5.4.140.0040.01212.75
5.4.130.0080.01612.81
5.4.120.0050.01912.92
5.4.110.0060.01412.85
5.4.100.0050.01712.79
5.4.90.0070.01012.86
5.4.80.0040.01712.86
5.4.70.0050.01812.78
5.4.60.0040.01312.71
5.4.50.0060.01412.79
5.4.40.0060.01712.85
5.4.30.0040.01812.86
5.4.20.0040.02012.76
5.4.10.0040.01812.80
5.4.00.0050.01212.76
5.3.290.0040.01512.36
5.3.280.0050.01912.31
5.3.270.0080.01812.23
5.3.260.0070.01712.25
5.3.250.0050.01512.30
5.3.240.0020.01412.24
5.3.230.0030.01912.22
5.3.220.0060.01412.21
5.3.210.0050.01512.24
5.3.200.0040.01412.15
5.3.190.0050.01912.26
5.3.180.0070.01812.30
5.3.170.0040.02012.23
5.3.160.0040.01812.23
5.3.150.0030.01412.26
5.3.140.0070.01812.24
5.3.130.0050.01912.26
5.3.120.0060.01512.23
5.3.110.0060.01912.25
5.3.100.0060.01212.04
5.3.90.0050.01312.12
5.3.80.0030.01212.11
5.3.70.0050.01812.13
5.3.60.0050.02012.15
5.3.50.0040.01912.08
5.3.40.0030.01912.11
5.3.30.0030.02212.08
5.3.20.0040.01912.04
5.3.10.0050.01812.00
5.3.00.0060.01111.92
5.2.170.0170.05711.16
5.2.160.0100.03711.18
5.2.150.0070.05311.15
5.2.140.0070.04711.05
5.2.130.0030.06011.16
5.2.120.0070.04311.16
5.2.110.0030.05011.13
5.2.100.0070.06011.09
5.2.90.0100.02711.12
5.2.80.0070.06711.14
5.2.70.0030.06011.11
5.2.60.0000.04711.07
5.2.50.0100.05710.93
5.2.40.0070.05010.98
5.2.30.0000.07011.04
5.2.20.0030.04311.02
5.2.10.0070.04010.83
5.2.00.0030.03010.58
5.1.60.0070.04710.09
5.1.50.0070.0239.98
5.1.40.0100.04710.01
5.1.30.0030.05710.30
5.1.20.0070.04310.21
5.1.10.0000.04310.07
5.1.00.0000.02710.14
5.0.50.0030.0209.29
5.0.40.0000.0209.29
5.0.30.0000.0309.29
5.0.20.0000.0209.29
5.0.10.0030.0179.29
5.0.00.0030.0279.29
4.4.90.0030.0339.29
4.4.80.0000.0379.29
4.4.70.0000.0309.29
4.4.60.0000.0379.29
4.4.50.0070.0279.29
4.4.40.0000.0539.29
4.4.30.0000.0379.29
4.4.20.0030.0139.29
4.4.10.0000.0179.29
4.4.00.0000.0239.29
4.3.110.0000.0179.29
4.3.100.0000.0139.29
4.3.90.0030.0139.29
4.3.80.0030.0209.29
4.3.70.0000.0179.29
4.3.60.0000.0179.29
4.3.50.0000.0139.29
4.3.40.0000.0239.29
4.3.30.0030.0139.29
4.3.20.0000.0179.29
4.3.10.0030.0139.29
4.3.00.0030.0109.29

preferences:
55.85 ms | 401 KiB | 5 Q