3v4l.org

run code in 300+ PHP versions simultaneously
<?php $inputString = "80"; $pattern = '/[ \-]/'; $replacement = ''; $inputString = preg_replace($pattern,$replacement,$inputString); $inputString = trim($inputString); $count = strlen($inputString); //echo $inputString;exit; $rem = ($count%3); if ($rem == 1){ $pos =4; $count = ($count - $pos); } else if($rem == 2) { $pos = 2; $count = ($count - $pos); } $phoneNumber = ""; for($k=0;$k<$count;$k++){ if($k % 3 !=0 || $k == 0){ $phoneNumber = $phoneNumber.$inputString[$k]; $phoneNumber = trim($phoneNumber); }else{ $phoneNumber = $phoneNumber.'-'.$inputString[$k]; } } //echo $phoneNumber;exit; if($rem == 2){ if($count!=0){ $phoneNumber.= '-'; } $phoneNumber.= $inputString[$count].$inputString[$count+1]; }else if($rem == 1){ if($count!=0){ $phoneNumber.='-'; } $phoneNumber.= $inputString[$count].$inputString[$count+1].'-'.$inputString[$count+2].$inputString[$count+3]; } echo $phoneNumber;exit;

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.0150.00418.78
8.3.50.0050.01421.28
8.3.40.0110.00419.09
8.3.30.0070.00719.27
8.3.20.0000.00820.20
8.3.10.0080.00023.55
8.3.00.0080.00023.43
8.2.180.0170.00318.66
8.2.170.0140.00722.96
8.2.160.0070.00720.35
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0080.00026.16
8.2.120.0100.00620.95
8.2.110.0030.00722.37
8.2.100.0060.00618.16
8.2.90.0080.00019.30
8.2.80.0040.00418.05
8.2.70.0060.00318.00
8.2.60.0050.00318.05
8.2.50.0000.00918.07
8.2.40.0070.00022.29
8.2.30.0040.00420.72
8.2.20.0000.00818.11
8.2.10.0070.00418.02
8.2.00.0080.00018.13
8.1.280.0100.01025.92
8.1.270.0040.00424.66
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0090.00024.02
8.1.230.0000.01118.96
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0000.00917.60
8.1.190.0030.00617.47
8.1.180.0040.00418.10
8.1.170.0000.00918.63
8.1.160.0050.00220.76
8.1.150.0000.00718.89
8.1.140.0000.00819.67
8.1.130.0030.00317.77
8.1.120.0070.00317.60
8.1.110.0000.00717.52
8.1.100.0020.00517.59
8.1.90.0000.00717.61
8.1.80.0090.00017.50
8.1.70.0040.00417.65
8.1.60.0040.00417.67
8.1.50.0030.00517.74
8.1.40.0040.00417.70
8.1.30.0050.00317.83
8.1.20.0000.00917.67
8.1.10.0040.00417.67
8.1.00.0070.00017.67
8.0.300.0070.00018.77
8.0.290.0070.00016.88
8.0.280.0040.00418.43
8.0.270.0040.00417.01
8.0.260.0000.00717.34
8.0.250.0000.00717.14
8.0.240.0030.00317.05
8.0.230.0040.00417.04
8.0.220.0030.00317.24
8.0.210.0000.00717.14
8.0.200.0030.00317.17
8.0.190.0060.00317.13
8.0.180.0000.00717.14
8.0.170.0060.00317.17
8.0.160.0050.00217.21
8.0.150.0080.00017.05
8.0.140.0040.00317.06
8.0.130.0040.00413.48
8.0.120.0000.00717.10
8.0.110.0070.00017.17
8.0.100.0040.00417.22
8.0.90.0000.00716.96
8.0.80.0090.00617.09
8.0.70.0040.00417.02
8.0.60.0000.00817.25
8.0.50.0000.00717.01
8.0.30.0100.00717.28
8.0.20.0090.01117.46
8.0.10.0040.00417.29
8.0.00.0080.01217.06
7.4.330.0030.00316.68
7.4.320.0000.00616.80
7.4.300.0030.00316.69
7.4.290.0050.00316.67
7.4.280.0000.00916.78
7.4.270.0070.00016.71
7.4.260.0030.00716.71
7.4.250.0050.00316.67
7.4.240.0040.00316.81
7.4.230.0080.00016.75
7.4.220.0100.01016.85
7.4.210.0090.00716.76
7.4.200.0000.00716.58
7.4.160.0120.00816.91
7.4.150.0110.00617.40
7.4.140.0110.00917.86
7.4.130.0040.01316.82
7.4.120.0140.00516.78
7.4.110.0040.01416.85
7.4.100.0120.01016.83
7.4.90.0150.00616.72
7.4.80.0190.00319.39
7.4.70.0060.01516.71
7.4.60.0130.00716.78
7.4.50.0060.00916.70
7.4.40.0140.00316.72
7.4.30.0060.01216.61
7.4.00.0080.01015.32
7.3.330.0000.00613.46
7.3.320.0050.00013.43
7.3.310.0000.00716.59
7.3.300.0030.00316.40
7.3.290.0040.00416.39
7.3.280.0110.00616.54
7.3.270.0070.01117.40
7.3.260.0090.00916.54
7.3.250.0090.00816.64
7.3.240.0090.00916.64
7.3.230.0030.01416.55
7.3.210.0100.00716.53
7.3.200.0090.01216.77
7.3.190.0080.00816.61
7.3.180.0070.01016.54
7.3.170.0110.01016.65
7.3.160.0100.00716.70
7.3.120.0060.01115.00
7.3.110.0100.00615.12
7.3.100.0120.00415.10
7.3.90.0000.01514.82
7.3.80.0070.01015.05
7.3.70.0070.00715.05
7.3.60.0030.01015.09
7.3.50.0000.01214.98
7.3.40.0000.01714.75
7.3.30.0080.00815.01
7.3.20.0040.00816.91
7.3.10.0100.00716.89
7.3.00.0120.00316.94
7.2.330.0030.01416.88
7.2.320.0140.00316.78
7.2.310.0040.01316.65
7.2.300.0100.00716.91
7.2.290.0150.00616.99
7.2.250.0040.01515.21
7.2.240.0030.01315.44
7.2.230.0090.00615.29
7.2.220.0060.01015.34
7.2.210.0000.01515.17
7.2.200.0000.01915.34
7.2.190.0090.00915.29
7.2.180.0100.00715.45
7.2.170.0120.00315.40
7.2.00.0000.01019.65
7.1.330.0000.01716.21
7.1.320.0080.00816.12
7.1.310.0090.00616.11
7.1.300.0030.01315.61
7.1.290.0060.00915.73
7.1.280.0060.00616.06
7.1.270.0040.00416.05
7.1.260.0070.00716.09
7.1.100.0140.00816.75
7.1.70.0040.00417.47
7.1.60.0170.00719.06
7.1.50.0130.01317.16
7.1.00.0070.07322.35
7.0.200.0460.00314.64
7.0.60.0030.08319.95
7.0.50.0100.07717.91
7.0.40.0070.04019.98
7.0.30.0400.06720.02
7.0.20.0400.07020.09
7.0.10.0030.09020.14
7.0.00.0070.08720.34
5.6.280.0070.05021.08
5.6.210.0000.04320.55
5.6.200.0070.08018.21
5.6.190.0100.08720.73
5.6.180.0070.05020.48
5.6.170.0330.07320.41
5.6.160.0030.08720.48
5.6.150.0130.07018.12
5.6.140.0000.04718.12
5.6.130.0070.05018.16
5.6.120.0030.04021.02
5.6.110.0100.08021.08
5.6.100.0230.06721.01
5.6.90.0070.06721.03
5.6.80.0100.06320.38
5.5.350.4170.04020.34
5.5.340.0130.07717.98
5.5.330.0000.04320.07
5.5.320.0300.04720.17
5.5.310.0200.08020.50
5.5.300.0000.07317.95
5.5.290.0070.05318.02
5.5.280.0130.08020.80
5.5.270.0170.07020.68
5.5.260.0100.08720.64
5.5.250.0070.08720.69
5.5.240.0230.07020.07

preferences:
34.94 ms | 401 KiB | 5 Q