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$3$4", $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/*"). 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.0120.00316.97
8.3.50.0100.01017.83
8.3.40.0120.00318.91
8.3.30.0110.00418.97
8.3.20.0060.00318.86
8.3.10.0030.00620.83
8.3.00.0150.00019.38
8.2.180.0110.01117.00
8.2.170.0150.00022.96
8.2.160.0110.00419.16
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0030.00520.35
8.2.110.0090.00021.10
8.2.100.0040.00818.03
8.2.90.0030.00619.46
8.2.80.0030.00519.27
8.2.70.0000.00917.75
8.2.60.0030.00617.93
8.2.50.0000.00818.07
8.2.40.0040.00418.34
8.2.30.0000.00818.18
8.2.20.0040.00417.97
8.2.10.0040.00417.87
8.2.00.0000.00717.81
8.1.280.0070.01025.92
8.1.270.0000.00724.66
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.91
8.1.230.0120.00021.16
8.1.220.0040.00417.91
8.1.210.0000.00819.13
8.1.200.0030.00617.38
8.1.190.0000.00917.64
8.1.180.0080.00018.10
8.1.170.0040.00418.89
8.1.160.0070.00019.01
8.1.150.0050.00318.91
8.1.140.0050.00217.62
8.1.130.0000.00717.88
8.1.120.0040.00417.69
8.1.110.0000.00817.59
8.1.100.0070.00017.64
8.1.90.0050.00317.62
8.1.80.0070.00017.56
8.1.70.0040.00417.64
8.1.60.0030.00617.80
8.1.50.0030.00517.68
8.1.40.0080.00017.62
8.1.30.0040.00417.77
8.1.20.0030.00517.69
8.1.10.0040.00417.70
8.1.00.0000.00817.64
8.0.300.0000.00720.11
8.0.290.0000.00717.00
8.0.280.0070.00018.41
8.0.270.0000.00717.23
8.0.260.0050.00317.01
8.0.250.0070.00017.18
8.0.240.0040.00417.13
8.0.230.0000.00917.16
8.0.220.0000.00717.16
8.0.210.0030.00716.94
8.0.200.0060.00017.11
8.0.190.0000.00817.04
8.0.180.0040.00416.98
8.0.170.0000.00917.06
8.0.160.0000.00717.14
8.0.150.0070.00316.99
8.0.140.0080.00417.07
8.0.130.0060.00013.49
8.0.120.0080.00016.96
8.0.110.0000.00717.16
8.0.100.0040.00417.13
8.0.90.0040.00417.14
8.0.80.0040.01217.11
8.0.70.0040.00417.25
8.0.60.0000.00717.09
8.0.50.0040.00416.95
8.0.30.0090.01217.29
8.0.20.0090.01017.54
8.0.10.0000.00717.27
8.0.00.0130.00616.94
7.4.330.0050.00013.27
7.4.320.0030.00316.82
7.4.300.0000.00616.91
7.4.290.0080.00016.83
7.4.280.0000.00916.87
7.4.270.0080.00016.76
7.4.260.0030.00313.65
7.4.250.0060.00316.89
7.4.240.0000.00716.75
7.4.230.0000.00716.70
7.4.220.0220.00016.79
7.4.210.0100.01016.81
7.4.200.0070.00016.78
7.4.190.0050.00216.92
7.4.160.0050.01116.78
7.4.150.0130.00516.79
7.4.140.0100.01216.76
7.4.130.0130.00516.84
7.4.120.0130.00516.92
7.4.110.0080.01217.03
7.4.100.0150.00316.64
7.4.90.0070.01016.82
7.4.80.0060.01216.84
7.4.70.0150.00416.77
7.4.60.0060.01116.82
7.4.50.0070.00716.57
7.4.40.0100.00716.69
7.4.30.0120.00616.86
7.4.00.0040.01115.30
7.3.330.0000.00713.45
7.3.320.0050.00013.49
7.3.310.0000.00716.53
7.3.300.0070.00016.45
7.3.290.0080.00816.50
7.3.280.0070.01016.47
7.3.270.0090.00916.74
7.3.260.0090.01116.82
7.3.250.0100.00916.66
7.3.240.0140.00416.52
7.3.230.0060.01116.55
7.3.210.0130.00616.49
7.3.200.0170.00019.39
7.3.190.0180.00416.77
7.3.180.0110.00616.63
7.3.170.0100.01016.59
7.3.160.0130.00316.75
7.3.120.0000.01115.00
7.3.10.0100.00316.64
7.3.00.0060.00816.73
7.2.330.0120.00616.98
7.2.320.0120.00916.85
7.2.310.0030.01616.74
7.2.300.0070.01116.88
7.2.290.0150.00417.02
7.2.130.0070.00717.13
7.2.120.0120.00416.84
7.2.110.0070.00916.93
7.2.100.0110.00617.00
7.2.90.0060.00717.02
7.2.80.0050.00917.04
7.2.70.0050.01117.16
7.2.60.0070.00817.15
7.2.50.0050.00916.96
7.2.40.0070.00617.07
7.2.30.0090.00516.95
7.2.20.0040.01117.06
7.2.10.0080.00817.05
7.2.00.0040.00917.74
7.1.250.0030.01115.76
7.1.240.0110.00615.98
7.1.230.0030.01116.04
7.1.220.0090.00615.84
7.1.210.0060.00915.91
7.1.200.0100.01016.11
7.1.190.0090.00715.84
7.1.180.0100.00615.67
7.1.170.0070.00415.82
7.1.160.0090.00515.65
7.1.150.0030.01015.89
7.1.140.0060.00515.95
7.1.130.0000.01116.03
7.1.120.0040.00815.71
7.1.110.0040.01015.96
7.1.100.0080.00616.71
7.1.90.0030.01015.75
7.1.80.0080.00515.81
7.1.70.0040.00916.40
7.1.60.0070.00617.17
7.1.50.0050.01116.40
7.1.40.0060.00615.82
7.1.30.0060.01015.92
7.1.20.0030.01016.04
7.1.10.0100.00816.04
7.1.00.0070.02118.11
7.0.330.0070.01015.16
7.0.320.0100.00515.53
7.0.310.0080.01015.36
7.0.300.0100.00215.65
7.0.290.0030.01015.21
7.0.280.0060.01015.39
7.0.270.0090.00815.25
7.0.260.0090.00915.39
7.0.250.0120.00515.52
7.0.240.0070.00615.51
7.0.230.0100.00415.61
7.0.220.0070.00715.69
7.0.210.0050.00815.39
7.0.200.0040.00815.26
7.0.190.0040.00815.51
7.0.180.0060.01015.42
7.0.170.0140.00315.55
7.0.160.0090.00915.60
7.0.150.0060.00915.29
7.0.140.0100.02917.56
7.0.130.0090.00715.50
7.0.120.0040.02817.54
7.0.110.0070.01015.30
7.0.100.0140.00415.56
7.0.90.0080.00915.58
7.0.80.0100.00815.53
7.0.70.0070.01015.47
7.0.60.0120.01616.99
7.0.50.0060.02216.38
7.0.40.0030.02015.04
7.0.30.0070.03115.05
7.0.20.0110.01914.96
7.0.10.0090.03414.91
7.0.00.0080.03814.82
5.6.380.0080.00614.36
5.6.370.0010.01314.20
5.6.360.0030.00814.49
5.6.350.0030.01014.32
5.6.340.0080.00514.37
5.6.330.0090.00714.38
5.6.320.0100.00714.53
5.6.310.0080.00814.43
5.6.300.0090.00614.58
5.6.290.0030.01114.49
5.6.280.0070.02916.47
5.6.270.0090.00614.22
5.6.260.0060.00814.52
5.6.250.0040.01314.28
5.6.240.0070.00914.33
5.6.230.0070.00814.25
5.6.220.0050.01214.33
5.6.210.0050.02316.49
5.6.200.0090.03015.68
5.6.190.0060.03015.81
5.6.180.0090.03215.52
5.6.170.0090.03415.50
5.6.160.0060.03315.68
5.6.150.0200.02215.60
5.6.140.0100.03315.63
5.6.130.0080.02715.49
5.6.120.0050.03515.59
5.6.110.0090.03215.67
5.6.100.0100.03015.43
5.6.90.0070.02615.51
5.6.80.0060.02015.33
5.6.70.0110.02815.42
5.6.60.0040.02215.35
5.6.50.0120.01615.35
5.6.40.0100.02915.33
5.6.30.0080.02015.48
5.6.20.0130.02515.42
5.6.10.0050.02215.20
5.6.00.0120.02215.48
5.5.380.0040.00711.18
5.5.370.0020.00911.20
5.5.360.0040.00711.29
5.5.350.0130.02914.19
5.5.340.0040.03113.50
5.5.330.0070.03013.43
5.5.320.0090.02313.43
5.5.310.0060.03213.40
5.5.300.0100.02913.50
5.5.290.0090.02913.42
5.5.280.0070.02513.36
5.5.270.0040.03413.34
5.5.260.0060.03313.42
5.5.250.0060.02613.40
5.5.240.0040.02913.24
5.5.230.0080.01913.06
5.5.220.0120.01713.25
5.5.210.0070.02613.20
5.5.200.0060.02113.11
5.5.190.0070.02713.25
5.5.180.0070.03013.18
5.5.170.0060.00711.18
5.5.160.0080.02513.07
5.5.150.0020.01913.21
5.5.140.0070.02913.27
5.5.130.0050.02813.29
5.5.120.0020.02713.11
5.5.110.0070.02513.25
5.5.100.0090.02813.16
5.5.90.0010.03313.21
5.5.80.0070.02613.19
5.5.70.0050.02913.20
5.5.60.0090.02813.09
5.5.50.0050.02213.27
5.5.40.0080.01513.13
5.5.30.0090.02513.18
5.5.20.0040.02713.11
5.5.10.0030.03113.24
5.5.00.0110.02513.16
5.4.450.0090.03113.88
5.4.440.0070.02713.82
5.4.430.0050.03313.88
5.4.420.0060.02613.90
5.4.410.0070.02413.79
5.4.400.0040.01713.63
5.4.390.0030.03213.82
5.4.380.0070.02613.56
5.4.370.0080.01613.65
5.4.360.0050.02113.72
5.4.350.0070.01813.78
5.4.340.0050.02013.79
5.4.330.0040.00911.10
5.4.320.0040.02013.81
5.4.310.0040.02213.74
5.4.300.0080.02913.86
5.4.290.0050.02213.90
5.4.280.0090.01613.62
5.4.270.0070.02513.76
5.4.260.0050.02913.72
5.4.250.0070.02213.70
5.4.240.0080.02913.67
5.4.230.0040.02713.78
5.4.220.0070.03013.65
5.4.210.0050.03213.77
5.4.200.0060.01613.72
5.4.190.0030.03013.87
5.4.180.0060.02913.72
5.4.170.0080.02013.79
5.4.160.0100.02413.75
5.4.150.0060.02613.65
5.4.140.0060.02612.92
5.4.130.0070.02512.85
5.4.120.0080.02312.91
5.4.110.0050.03012.78
5.4.100.0080.02912.93
5.4.90.0090.02712.85
5.4.80.0080.01612.84
5.4.70.0030.02412.84
5.4.60.0040.03012.89
5.4.50.0100.02912.88
5.4.40.0080.01912.71
5.4.30.0090.02512.88
5.4.20.0040.02812.78
5.4.10.0070.02812.90
5.4.00.0080.02512.69
5.3.290.0060.02612.25
5.3.280.0070.03012.15
5.3.270.0070.02712.12
5.3.260.0050.01612.17
5.3.250.0060.02712.17
5.3.240.0090.02512.03
5.3.230.0050.03112.14
5.3.220.0040.02112.19
5.3.210.0050.02012.10
5.3.200.0100.02512.12
5.3.190.0030.02312.07
5.3.180.0110.01512.09
5.3.170.0080.02812.16
5.3.160.0070.02312.06
5.3.150.0100.02612.11
5.3.140.0060.01912.15
5.3.130.0080.01912.09
5.3.120.0070.02712.14
5.3.110.0050.03012.08
5.3.100.0080.03011.89
5.3.90.0040.02211.95
5.3.80.0110.02211.92
5.3.70.0070.02911.94
5.3.60.0130.03011.99
5.3.50.0130.02711.91
5.3.40.0140.02711.83
5.3.30.0140.02211.86
5.3.20.0100.02711.85
5.3.10.0040.02611.76
5.3.00.0020.02711.75
5.2.170.0110.02010.81
5.2.160.0080.02110.87
5.2.150.0160.01910.88
5.2.140.0100.02010.81
5.2.130.0050.01510.85
5.2.120.0100.02010.80
5.2.110.0040.02310.84
5.2.100.0040.02610.85
5.2.90.0030.02210.84
5.2.80.0080.02210.82
5.2.70.0050.02110.87
5.2.60.0060.02010.84
5.2.50.0060.01610.81
5.2.40.0040.02410.79
5.2.30.0070.02310.81
5.2.20.0050.01510.76
5.2.10.0060.02310.77
5.2.00.0070.02410.70
5.1.60.0040.02010.48
5.1.50.0030.02110.54
5.1.40.0040.01610.47
5.1.30.0040.02010.59
5.1.20.0000.01810.61
5.1.10.0010.01910.52
5.1.00.0050.02110.51
5.0.50.0060.01710.01
5.0.40.0040.0089.97
5.0.30.0030.0229.95
5.0.20.0030.0169.89
5.0.10.0050.0159.89
5.0.00.0020.0169.87
4.4.90.0010.0129.67
4.4.80.0030.0109.67
4.4.70.0060.0079.67
4.4.60.0030.0109.67
4.4.50.0030.0159.67
4.4.40.0040.0229.67
4.4.30.0060.0129.67
4.4.20.0010.0109.67
4.4.10.0040.0129.67
4.4.00.0010.0179.67
4.3.110.0000.0189.67
4.3.100.0010.0169.67
4.3.90.0070.0119.67
4.3.80.0000.0219.67
4.3.70.0020.0149.67
4.3.60.0020.0129.67
4.3.50.0030.0109.67
4.3.40.0020.0159.67
4.3.30.0030.0189.67
4.3.20.0040.0139.67
4.3.10.0020.0129.67
4.3.00.0010.0149.67

preferences:
42.25 ms | 401 KiB | 5 Q