3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "mozzzaaaaaarelaaaaaa"; $string = preg_replace('/^-+/','',$string); echo $string; function setString($phrase, $length = null) { $result = strtolower($phrase); $result = trim(preg_replace("/[^0-9a-zA-Z-]/", "-", $result)); $result = preg_replace("/--+/", "-", $result); $result = !empty($length) ? substr($result, 0, $length) : $result; // remove hyphen from the beginning (if exists) $first_char = substr($result, 0, 1); $result = $first_char == "-" ? substr($result, 1) : $result; // remove hyphen from the end (if exists) $last_char = substr($result, -1); $result = $last_char == "-" ? substr($result, 0, -1) : $result; return $result; } echo setString($string);

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.00318.55
8.3.50.0090.01023.01
8.3.40.0090.00918.88
8.3.30.0110.00418.96
8.3.20.0070.00020.34
8.3.10.0000.00723.61
8.3.00.0000.00819.51
8.2.180.0040.01118.66
8.2.170.0110.00422.96
8.2.160.0170.00320.52
8.2.150.0000.00724.18
8.2.140.0060.00324.66
8.2.130.0030.00526.16
8.2.120.0000.00821.14
8.2.110.0050.00520.56
8.2.100.0110.00018.03
8.2.90.0080.00019.21
8.2.80.0050.00317.97
8.2.70.0080.00217.75
8.2.60.0040.00418.03
8.2.50.0000.00918.07
8.2.40.0060.00318.22
8.2.30.0040.00418.20
8.2.20.0040.00417.89
8.2.10.0070.00018.22
8.2.00.0030.00617.79
8.1.280.0070.00725.92
8.1.270.0040.00423.91
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0090.00022.62
8.1.230.0040.00719.09
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0020.01017.25
8.1.190.0050.00317.35
8.1.180.0000.00918.10
8.1.170.0090.00318.76
8.1.160.0020.00522.04
8.1.150.0000.00718.96
8.1.140.0030.00617.62
8.1.130.0040.00417.92
8.1.120.0000.00717.63
8.1.110.0030.00517.61
8.1.100.0040.00417.60
8.1.90.0040.00417.51
8.1.80.0040.00317.52
8.1.70.0030.00317.51
8.1.60.0000.00817.73
8.1.50.0050.00317.60
8.1.40.0040.00417.54
8.1.30.0050.00317.75
8.1.20.0000.00817.74
8.1.10.0030.00617.71
8.1.00.0030.00517.46
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0030.00318.36
8.0.270.0040.00417.18
8.0.260.0040.00417.34
8.0.250.0070.00017.00
8.0.240.0030.00517.07
8.0.230.0080.00017.09
8.0.220.0000.00717.07
8.0.210.0000.00716.95
8.0.200.0000.00717.10
8.0.190.0060.00317.08
8.0.180.0070.00316.96
8.0.170.0040.00416.96
8.0.160.0000.00716.98
8.0.150.0060.00616.95
8.0.140.0000.00717.04
8.0.130.0000.00813.43
8.0.120.0040.00416.95
8.0.110.0040.00417.02
8.0.100.0000.00717.07
8.0.90.0050.00316.95
8.0.80.0060.01217.08
8.0.70.0000.00716.96
8.0.60.0030.00517.09
8.0.50.0000.00716.82
8.0.30.0100.00917.30
8.0.20.0160.01317.40
8.0.10.0000.00717.14
8.0.00.0110.00716.92
7.4.330.0060.00015.12
7.4.320.0000.00716.73
7.4.300.0000.00616.74
7.4.290.0030.00316.78
7.4.280.0110.00016.75
7.4.270.0030.00716.73
7.4.260.0060.00316.73
7.4.250.0080.00016.82
7.4.240.0020.00616.77
7.4.230.0070.00016.61
7.4.220.0140.00816.83
7.4.210.0100.00616.93
7.4.200.0050.00216.76
7.4.160.0080.00816.60
7.4.150.0110.00717.40
7.4.140.0140.00517.86
7.4.130.0060.01016.80
7.4.120.0090.00816.85
7.4.110.0130.00316.65
7.4.100.0100.00716.56
7.4.90.0100.00716.73
7.4.80.0060.01119.39
7.4.70.0060.01316.67
7.4.60.0040.01416.57
7.4.50.0040.00416.40
7.4.40.0130.00316.85
7.4.30.0110.00516.61
7.4.00.0030.01415.28
7.3.330.0030.00313.51
7.3.320.0030.00213.40
7.3.310.0040.00416.35
7.3.300.0030.00316.45
7.3.290.0170.00416.43
7.3.280.0080.01116.47
7.3.270.0070.01017.40
7.3.260.0030.01316.52
7.3.250.0120.00716.73
7.3.240.0110.01116.57
7.3.230.0070.01016.61
7.3.210.0130.01016.59
7.3.200.0050.01119.39
7.3.190.0090.00916.47
7.3.180.0070.01016.70
7.3.170.0160.00016.48
7.3.160.0070.01116.92
7.2.330.0030.01616.85
7.2.320.0030.01316.79
7.2.310.0070.01616.82
7.2.300.0030.01316.77
7.2.290.0070.01016.83
7.2.60.0110.00316.56
7.2.50.0110.00717.13
7.1.200.0090.00915.88
7.1.70.0110.00417.29
7.1.60.0070.01719.46
7.1.50.0060.01917.20
7.1.00.0000.08022.43
7.0.200.0000.00916.86
7.0.140.0070.07021.96
7.0.60.0030.04319.87
7.0.50.0070.07717.90
7.0.40.0070.06720.11
7.0.30.0270.04720.08
7.0.20.0200.05720.12
7.0.10.0070.08020.18
7.0.00.0170.07320.11
5.6.280.0030.07321.04
5.6.210.0100.05720.55
5.6.200.0130.04318.11
5.6.190.0100.08320.61
5.6.180.0470.05020.77
5.6.170.0230.08320.76
5.6.160.0070.08720.50
5.6.150.0100.06718.23
5.6.140.0070.03718.14
5.6.130.0000.06318.18
5.6.120.0070.04320.95
5.6.110.0030.09321.06
5.6.100.0200.07021.01
5.6.90.0070.08321.02
5.6.80.0100.06320.41
5.5.350.0230.07720.37
5.5.340.0030.04018.07
5.5.330.0100.04320.35
5.5.320.0400.05320.34
5.5.310.0370.06020.51
5.5.300.0000.04018.07
5.5.290.0070.06317.91
5.5.280.0030.09020.77
5.5.270.0030.05020.81
5.5.260.0030.04320.79
5.5.250.0100.03720.55
5.5.240.0200.04720.23
5.4.450.0400.04019.50
5.4.440.0170.04019.64
5.4.430.0570.03719.43
5.4.420.0130.03719.41
5.4.410.0300.04719.39
5.4.400.0230.03019.14
5.4.390.0170.04719.08
5.4.380.0530.07018.74
5.4.370.0430.07318.81
5.4.360.0800.06718.75
5.4.350.0570.07018.72
5.4.340.0270.07018.70
5.4.320.0070.03512.50
5.4.310.0050.04912.50
5.4.300.0120.03712.51
5.4.290.0070.04112.50
5.4.280.0100.03912.40
5.4.270.0070.03412.39
5.4.260.0080.03512.40
5.4.250.0070.03612.39
5.4.240.0030.04212.39
5.4.230.0100.03912.39
5.4.220.0040.03912.39
5.4.210.0060.04312.39
5.4.200.0080.04312.39
5.4.190.0100.03712.39
5.4.180.0070.04412.38
5.4.170.0050.04712.40
5.4.160.0060.04212.39
5.4.150.0060.03512.39
5.4.140.0060.03612.07
5.4.130.0060.03512.06
5.4.120.0090.03212.01
5.4.110.0060.03612.02
5.4.100.0060.04212.02
5.4.90.0080.03712.01
5.4.80.0050.04512.01
5.4.70.0010.04112.01
5.4.60.0040.03712.01
5.4.50.0060.03612.01
5.4.40.0060.04212.00
5.4.30.0060.04112.00
5.4.20.0090.03311.99
5.4.10.0080.03911.99
5.4.00.0050.04111.48
5.3.290.0070.04912.80
5.3.280.0100.03712.71
5.3.270.0090.04312.72
5.3.260.0040.04512.72
5.3.250.0120.04112.72
5.3.240.0060.04712.72
5.3.230.0030.04012.71
5.3.220.0040.03912.68
5.3.210.0070.03912.68
5.3.200.0070.04212.68
5.3.190.0060.04512.68
5.3.180.0090.04212.67
5.3.170.0110.04312.67
5.3.160.0040.05012.67
5.3.150.0100.03912.67
5.3.140.0130.03912.66
5.3.130.0090.05412.66
5.3.120.0080.05012.66
5.3.110.0100.04212.66
5.3.100.0040.03912.13
5.3.90.0060.03612.11
5.3.80.0090.03312.10
5.3.70.0090.04312.11
5.3.60.0060.03712.09
5.3.50.0060.03712.04
5.3.40.0050.03712.05
5.3.30.0050.03511.99
5.3.20.0060.04511.77
5.3.10.0110.03411.74
5.3.00.0040.04411.73
5.2.170.0110.0339.23
5.2.160.0080.0479.23
5.2.150.0060.0379.23
5.2.140.0090.0359.23
5.2.130.0060.0379.19
5.2.120.0070.0319.19
5.2.110.0090.0299.20
5.2.100.0060.0349.19
5.2.90.0110.0409.19
5.2.80.0020.0339.19
5.2.70.0060.0409.18
5.2.60.0060.0459.14
5.2.50.0100.0379.11
5.2.40.0090.0309.09
5.2.30.0110.0259.06
5.2.20.0050.0289.05
5.2.10.0020.0318.94
5.2.00.0040.0298.80
5.1.60.0060.0228.09
5.1.50.0020.0278.09
5.1.40.0020.0378.07
5.1.30.0070.0308.41
5.1.20.0080.0338.44
5.1.10.0030.0308.16
5.1.00.0060.0238.16
5.0.50.0060.0256.66
5.0.40.0030.0266.52
5.0.30.0020.0326.33
5.0.20.0050.0246.30
5.0.10.0030.0366.28
5.0.00.0060.0346.27
4.4.90.0050.0224.78
4.4.80.0040.0254.76
4.4.70.0050.0204.76
4.4.60.0050.0234.75
4.4.50.0030.0204.77
4.4.40.0040.0344.70
4.4.30.0070.0184.76
4.4.20.0040.0254.84
4.4.10.0080.0294.85
4.4.00.0030.0344.76
4.3.110.0020.0324.67
4.3.100.0040.0264.66
4.3.90.0050.0204.64
4.3.80.0020.0294.59
4.3.70.0060.0174.63
4.3.60.0050.0164.63
4.3.50.0040.0164.63
4.3.40.0020.0354.54
4.3.30.0010.0213.32
4.3.20.0030.0203.30
4.3.10.0040.0193.26
4.3.00.0030.01718.23

preferences:
48.15 ms | 404 KiB | 6 Q