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?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.70.0100.00616.88
8.3.60.0090.01216.75
8.3.50.0080.01022.10
8.3.40.0140.00419.14
8.3.30.0100.00319.09
8.3.20.0070.00020.29
8.3.10.0030.00623.52
8.3.00.0000.00820.64
8.2.180.0090.00616.88
8.2.170.0110.00422.96
8.2.160.0140.00022.25
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0030.00626.16
8.2.120.0040.00422.24
8.2.110.0090.00020.55
8.2.100.0090.00318.09
8.2.90.0040.00419.52
8.2.80.0030.00518.05
8.2.70.0030.00617.75
8.2.60.0050.00318.05
8.2.50.0050.00518.07
8.2.40.0000.00819.54
8.2.30.0070.00018.09
8.2.20.0030.00517.98
8.2.10.0080.00018.06
8.2.00.0060.00317.93
8.1.280.0090.00625.92
8.1.270.0050.00323.79
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0000.01023.82
8.1.230.0110.00023.85
8.1.220.0040.00417.78
8.1.210.0080.00018.77
8.1.200.0060.00317.60
8.1.190.0040.00417.55
8.1.180.0040.00418.10
8.1.170.0040.00418.84
8.1.160.0080.00022.11
8.1.150.0040.00418.90
8.1.140.0030.00617.69
8.1.130.0000.00717.98
8.1.120.0000.00817.52
8.1.110.0000.00717.55
8.1.100.0040.00417.62
8.1.90.0030.00517.67
8.1.80.0070.00017.72
8.1.70.0000.00817.59
8.1.60.0090.00017.68
8.1.50.0030.00517.66
8.1.40.0000.00817.59
8.1.30.0000.00817.88
8.1.20.0030.00517.77
8.1.10.0000.00817.73
8.1.00.0080.00017.57
8.0.300.0080.00018.77
8.0.290.0000.00717.30
8.0.280.0000.00718.59
8.0.270.0000.00717.35
8.0.260.0030.00317.07
8.0.250.0000.00717.05
8.0.240.0060.00517.15
8.0.230.0040.00417.05
8.0.220.0030.00317.14
8.0.210.0000.00717.03
8.0.200.0030.00317.08
8.0.190.0040.00417.10
8.0.180.0000.00817.18
8.0.170.0080.00017.13
8.0.160.0000.00717.02
8.0.150.0100.00016.94
8.0.140.0040.00416.96
8.0.130.0000.00613.50
8.0.120.0040.00417.05
8.0.110.0030.00417.13
8.0.100.0030.00517.28
8.0.90.0000.00717.20
8.0.80.0090.00917.09
8.0.70.0040.00417.19
8.0.60.0080.00017.16
8.0.50.0000.00717.13
8.0.30.0100.00817.35
8.0.20.0150.00717.41
8.0.10.0040.00417.24
8.0.00.0080.01017.13
7.4.330.0000.00515.06
7.4.320.0030.00316.82
7.4.300.0040.00416.89
7.4.290.0030.00316.84
7.4.280.0000.00816.92
7.4.270.0000.00716.77
7.4.260.0030.00516.91
7.4.250.0040.00416.93
7.4.240.0020.00516.90
7.4.230.0000.00716.67
7.4.220.0090.00916.90
7.4.210.0080.00716.89
7.4.200.0040.00416.84
7.4.190.0040.00416.77
7.4.160.0100.00716.71
7.4.150.0090.00917.40
7.4.140.0140.00317.86
7.4.130.0100.00716.74
7.4.120.0100.00816.76
7.4.110.0140.00316.60
7.4.100.0080.01116.93
7.4.90.0080.00916.81
7.4.80.0080.01116.82
7.4.70.0110.00716.60
7.4.60.0170.00016.69
7.4.50.0030.00616.73
7.4.40.0100.00622.77
7.4.30.0070.01116.70
7.4.10.0140.00716.87
7.4.00.0060.01316.00
7.3.330.0030.00313.50
7.3.320.0030.00313.36
7.3.310.0030.00316.50
7.3.300.0040.00416.39
7.3.290.0030.01116.50
7.3.280.0060.01216.51
7.3.270.0040.01417.40
7.3.260.0130.00716.80
7.3.250.0060.01616.53
7.3.240.0060.01116.79
7.3.230.0160.00616.76
7.3.210.0080.01116.59
7.3.200.0090.01519.39
7.3.190.0120.00916.78
7.3.180.0040.01216.79
7.3.170.0040.01216.71
7.3.160.0090.00916.80
7.3.130.0070.01316.46
7.3.120.0080.00515.84
7.3.110.0090.00616.61
7.3.100.0030.01316.34
7.3.90.0060.00916.48
7.3.80.0130.00316.38
7.3.70.0070.00416.54
7.3.60.0040.01216.37
7.3.50.0030.01216.70
7.3.40.0030.00716.57
7.3.30.0070.00716.63
7.3.20.0030.00718.37
7.3.10.0100.00318.23
7.3.00.0040.01118.27
7.2.330.0070.01116.66
7.2.320.0030.01516.91
7.2.310.0100.01416.65
7.2.300.0030.01416.91
7.2.290.0170.00016.86
7.2.260.0030.01716.75
7.2.250.0110.00716.69
7.2.240.0070.00716.63
7.2.230.0030.01316.89
7.2.220.0070.01116.79
7.2.210.0100.00716.90
7.2.200.0060.01316.79
7.2.190.0100.00716.62
7.2.180.0080.00516.61
7.2.170.0030.00616.84
7.2.160.0070.01016.74
7.2.150.0030.01318.42
7.2.140.0100.00618.47
7.2.130.0070.00718.54
7.2.120.0040.00718.64
7.2.110.0080.00818.55
7.2.100.0110.00018.66
7.2.90.0040.00818.45
7.2.80.0100.00718.63
7.2.70.0070.01018.62
7.2.60.0110.00018.47
7.2.50.0030.01018.54
7.2.40.0120.00318.55
7.2.30.0070.01018.68
7.2.20.0030.00718.57
7.2.10.0130.00018.64
7.2.00.0070.00518.93
7.1.330.0030.01017.64
7.1.320.0030.01017.38
7.1.310.0000.01017.53
7.1.300.0040.00717.41
7.1.290.0040.00817.52
7.1.280.0090.00617.71
7.1.270.0030.00717.50
7.1.260.0000.01417.54
7.1.250.0060.00617.27
7.1.240.0060.00317.58
7.1.230.0030.01217.54
7.1.220.0040.01117.55
7.1.210.0050.00517.55
7.1.200.0080.00516.87
7.1.190.0040.00717.39
7.1.180.0050.00517.41
7.1.170.0000.01317.60
7.1.160.0070.00417.50
7.1.150.0040.01117.54
7.1.140.0000.01317.58
7.1.130.0040.01217.52
7.1.120.0070.00717.66
7.1.110.0030.01017.66
7.1.100.0050.00917.85
7.1.90.0070.00417.53
7.1.80.0060.00317.64
7.1.70.0020.00917.38
7.1.60.0090.01118.46
7.1.50.0120.00917.37
7.1.40.0080.00417.51
7.1.30.0060.00917.63
7.1.20.0090.00617.59
7.1.10.0030.01017.41
7.1.00.0080.03819.97
7.0.330.0110.00417.04
7.0.320.0060.00917.26
7.0.310.0100.00716.95
7.0.300.0000.01117.15
7.0.290.0040.01117.14
7.0.280.0030.00716.98
7.0.270.0030.01417.20
7.0.260.0030.01417.04
7.0.250.0060.00917.20
7.0.240.0060.01017.19
7.0.230.0070.00717.00
7.0.220.0040.00417.18
7.0.210.0030.01017.16
7.0.200.0090.00316.96
7.0.190.0080.00817.15
7.0.180.0080.00317.23
7.0.170.0070.00317.38
7.0.160.0030.01417.09
7.0.150.0120.00317.39
7.0.140.0060.03919.68
7.0.130.0090.00316.99
7.0.120.0060.00617.16
7.0.110.0070.00316.99
7.0.100.0080.04618.51
7.0.90.0070.04518.48
7.0.80.0080.03718.68
7.0.70.0030.03518.61
7.0.60.0080.05018.61
7.0.50.0150.03818.73
7.0.40.0070.04617.56
7.0.30.0120.04117.65
7.0.20.0070.04917.56
7.0.10.0030.04317.49
7.0.00.0070.04417.66
5.6.400.0030.01016.09
5.6.390.0030.01216.11
5.6.380.0040.00816.28
5.6.370.0070.00316.21
5.6.360.0030.00716.35
5.6.350.0030.01315.86
5.6.340.0040.00715.88
5.6.330.0040.01216.06
5.6.320.0070.00716.14
5.6.310.0130.00015.70
5.6.300.0050.00516.19
5.6.290.0070.00716.22
5.6.280.0030.04318.52
5.6.270.0040.01515.94
5.6.260.0070.00715.96
5.6.250.0030.02818.30
5.6.240.0050.04718.33
5.6.230.0080.04418.27
5.6.220.0070.02518.19
5.6.210.0070.04418.22
5.6.200.0070.04718.47
5.6.190.0070.04718.55
5.6.180.0080.04518.41
5.6.170.0080.04518.42
5.6.160.0090.03918.57
5.6.150.0070.04118.54
5.6.140.0050.04218.58
5.6.130.0060.04318.52
5.6.120.0050.04318.47
5.6.110.0070.03518.54
5.6.100.0090.04118.36
5.6.90.0070.04418.58
5.6.80.0120.03718.20
5.6.70.0070.04218.12
5.6.60.0080.04318.25
5.6.50.0090.04118.13
5.6.40.0050.04718.22
5.6.30.0050.03018.20
5.6.20.0090.03818.16
5.6.10.0080.04518.19
5.6.00.0070.03818.12
5.5.380.0090.02118.20
5.5.370.0120.04118.27
5.5.360.0050.04618.20
5.5.350.0070.02818.20
5.5.340.0080.04218.49
5.5.330.0080.04618.40
5.5.320.0100.04218.48
5.5.310.0080.04218.33
5.5.300.0030.03518.45
5.5.290.0050.04618.29
5.5.280.0120.03318.43
5.5.270.0030.04518.37
5.5.260.0110.03118.28
5.5.250.0030.04718.31
5.5.240.0050.03418.03
5.5.230.0030.04618.05
5.5.220.0050.04518.04
5.5.210.0090.04118.04
5.5.200.0120.03518.02
5.5.190.0030.03018.02
5.5.180.0050.04718.06
5.5.170.0150.00015.72
5.5.160.0150.03317.99
5.5.150.0150.03417.90
5.5.140.0130.03218.08
5.5.130.0070.03717.85
5.5.120.0050.03218.03
5.5.110.0060.03017.89
5.5.100.0050.05218.02
5.5.90.0090.04117.88
5.5.80.0070.04517.99
5.5.70.0140.03717.94
5.5.60.0050.04517.84
5.5.50.0050.04917.93
5.5.40.0060.04318.03
5.5.30.0100.04217.96
5.5.20.0050.03617.88
5.5.10.0030.04517.99
5.5.00.0050.04417.81
5.4.450.0030.04716.75
5.4.440.0070.03816.72
5.4.430.0070.02616.63
5.4.420.0080.03816.76
5.4.410.0070.04516.54
5.4.400.0050.04216.58
5.4.390.0020.04016.52
5.4.380.0050.04516.45
5.4.370.0080.04016.57
5.4.360.0060.04616.55
5.4.350.0080.03816.58
5.4.340.0070.04116.61
5.4.330.0000.00813.98
5.4.320.0050.04016.56
5.4.310.0090.03316.47
5.4.300.0080.03816.57
5.4.290.0050.03316.44
5.4.280.0080.04016.55
5.4.270.0110.02816.56
5.4.260.0080.03816.44
5.4.250.0030.03916.50
5.4.240.0080.03916.44
5.4.230.0090.03716.57
5.4.220.0080.04016.42
5.4.210.0030.04116.56
5.4.200.0070.04016.49
5.4.190.0030.03616.55
5.4.180.0120.03716.60
5.4.170.0100.03516.50
5.4.160.0070.03316.50
5.4.150.0000.04416.46
5.4.140.0060.02715.13
5.4.130.0090.03715.21
5.4.120.0090.04115.11
5.4.110.0050.04315.27
5.4.100.0050.03915.23
5.4.90.0070.03215.23
5.4.80.0030.02715.22
5.4.70.0070.03715.25
5.4.60.0050.04215.23
5.4.50.0080.03515.18
5.4.40.0020.03715.26
5.4.30.0030.04115.21
5.4.20.0080.03015.21
5.4.10.0120.03515.22
5.4.00.0070.03814.94
5.3.290.0060.02614.29
5.3.280.0070.03514.29
5.3.270.0100.02714.28
5.3.260.0050.03914.35
5.3.250.0130.02714.34
5.3.240.0080.04314.36
5.3.230.0050.04114.35
5.3.220.0080.02414.35
5.3.210.0100.04014.31
5.3.200.0070.03514.30
5.3.190.0040.04414.28
5.3.180.0080.03214.25
5.3.170.0030.03714.33
5.3.160.0100.04114.26
5.3.150.0100.03414.30
5.3.140.0050.04414.27
5.3.130.0100.03614.33
5.3.120.0050.04314.27
5.3.110.0100.04014.28
5.3.100.0050.03514.04
5.3.90.0050.04113.99
5.3.80.0020.04214.03
5.3.70.0070.03713.96
5.3.60.0020.04914.00
5.3.50.0030.04513.96
5.3.40.0030.04014.00
5.3.30.0080.04113.97
5.3.20.0080.03813.83
5.3.10.0050.03713.83
5.3.00.0070.03713.76
5.2.170.0030.06311.75
5.2.160.0070.06311.75
5.2.150.0000.06011.75
5.2.140.0000.06011.75
5.2.130.0070.05711.75
5.2.120.0070.05711.75
5.2.110.0030.06711.75
5.2.100.0030.07311.75
5.2.90.0000.06311.75
5.2.80.0030.06311.75
5.2.70.0170.05311.75
5.2.60.0000.06011.75
5.2.50.0030.05311.75
5.2.40.0070.06011.75
5.2.30.0030.06711.75
5.2.20.0100.05311.75
5.2.10.0070.06011.75
5.2.00.0030.03711.75
5.1.60.0070.05011.75
5.1.50.0030.04711.75
5.1.40.0070.05011.75
5.1.30.0070.05311.75
5.1.20.0070.05311.75
5.1.10.0000.05711.75
5.1.00.0070.05711.75
5.0.50.0000.05011.75
5.0.40.0030.04311.75
5.0.30.0070.06311.75
5.0.20.0000.05011.75
5.0.10.0030.04311.75
5.0.00.0030.05711.75
4.4.90.0000.02311.75
4.4.80.0000.03011.75
4.4.70.0000.04011.75
4.4.60.0030.03311.75
4.4.50.0000.03311.75
4.4.40.0000.04011.75
4.4.30.0070.02711.75
4.4.20.0000.02711.75
4.4.10.0170.02711.75
4.4.00.0070.05011.75
4.3.110.0070.03311.75
4.3.100.0030.02711.75
4.3.90.0000.03311.75
4.3.80.0100.05011.75
4.3.70.0000.03311.75
4.3.60.0100.02011.75
4.3.50.0100.02711.75
4.3.40.0070.04711.75
4.3.30.0070.03011.75
4.3.20.0000.04011.75
4.3.10.0000.03711.75
4.3.00.0030.02711.75

preferences:
55.73 ms | 401 KiB | 5 Q