3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($number) { if (!IsValidNumber($number)) { throw new \Exception('Invalid phone number'); } return preg_replace('/[^0-9]/', '', $number); } function IsValidNumber($number) { $validChars = array(' ', '-'); if (!is_numeric(substr($number, 0, 1)) || !is_numeric(substr($number, strlen($number) - 1, 1)) ) { return false; } $delimiterFlag = false; foreach (str_split($number) as $digit) { if (!is_numeric($digit) && !in_array($digit, $validChars)) { return false; } if (in_array($digit, $validChars)) { if ($delimiterFlag) { return false; } $delimiterFlag = true; } else { $delimiterFlag = false; } } return true; } echo ReformatPhoneNumber('012-345 69');

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.40.0130.00918.85
8.3.30.0060.00918.92
8.3.20.0000.00820.34
8.3.10.0080.00023.46
8.3.00.0060.00319.23
8.2.170.0040.01122.96
8.2.160.0110.00320.38
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0000.01422.10
8.2.110.0110.00720.53
8.2.100.0090.00317.84
8.2.90.0000.00819.04
8.2.80.0000.00818.05
8.2.70.0030.00617.75
8.2.60.0000.00817.93
8.2.50.0060.00318.07
8.2.40.0080.00018.16
8.2.30.0040.00418.04
8.2.20.0090.00017.90
8.2.10.0040.00418.09
8.2.00.0050.00317.89
8.1.270.0080.00022.18
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0070.00323.86
8.1.230.0110.00023.85
8.1.220.0000.00917.74
8.1.210.0000.00818.77
8.1.200.0030.00617.35
8.1.190.0030.00617.53
8.1.180.0080.00018.10
8.1.170.0020.01118.63
8.1.160.0000.00721.96
8.1.150.0000.00818.91
8.1.140.0000.00717.66
8.1.130.0070.00017.86
8.1.120.0000.00717.69
8.1.110.0040.00417.60
8.1.100.0040.00417.55
8.1.90.0000.00717.52
8.1.80.0000.00717.59
8.1.70.0000.00717.54
8.1.60.0030.00617.67
8.1.50.0030.00617.72
8.1.40.0030.00617.57
8.1.30.0060.00317.80
8.1.20.0000.00717.82
8.1.10.0000.00817.70
8.1.00.0050.00317.54
8.0.300.0040.00418.77
8.0.290.0070.00017.16
8.0.280.0030.00318.39
8.0.270.0000.00717.23
8.0.260.0000.00716.91
8.0.250.0070.00017.16
8.0.240.0030.00317.07
8.0.230.0040.00417.00
8.0.220.0070.00017.03
8.0.210.0070.00017.07
8.0.200.0030.00317.12
8.0.190.0050.00316.96
8.0.180.0030.00617.05
8.0.170.0060.00317.11
8.0.160.0000.00716.91
8.0.150.0040.00416.96
8.0.140.0040.00417.04
8.0.130.0030.00313.55
8.0.120.0040.00416.90
8.0.110.0050.00316.98
8.0.100.0040.00417.03
8.0.90.0000.00717.04
8.0.80.0030.01217.00
8.0.70.0040.00417.09
8.0.60.0000.00716.93
8.0.50.0000.00817.16
8.0.30.0060.01317.07
8.0.20.0110.00817.50
8.0.10.0040.00416.99
8.0.00.0120.00917.00
7.4.330.0050.00015.09
7.4.320.0060.00016.80
7.4.300.0070.00016.74
7.4.290.0070.00016.70
7.4.280.0030.00816.77
7.4.270.0000.00716.84
7.4.260.0070.00016.80
7.4.250.0070.00016.83
7.4.240.0020.00516.82
7.4.230.0000.00716.85
7.4.220.0140.00316.93
7.4.210.0060.01416.73
7.4.200.0050.00316.66
7.4.190.0000.00716.98
7.4.160.0110.00716.67
7.4.150.0150.00917.40
7.4.140.0140.01017.86
7.4.130.0120.00716.80
7.4.120.0130.00516.81
7.4.110.0150.00816.78
7.4.100.0090.01516.66
7.4.90.0030.01316.53
7.4.80.0120.00819.39
7.4.70.0070.01016.71
7.4.60.0090.00616.64
7.4.50.0000.00916.62
7.4.40.0070.01022.77
7.4.30.0070.01016.71
7.4.10.0040.01415.98
7.4.00.0070.00915.72
7.3.330.0000.00613.39
7.3.320.0030.00313.41
7.3.310.0000.00816.52
7.3.300.0030.00316.51
7.3.290.0070.00716.54
7.3.280.0070.01016.47
7.3.270.0120.00617.40
7.3.260.0100.00716.86
7.3.250.0120.00716.44
7.3.240.0100.00716.46
7.3.230.0160.00016.82
7.3.210.0000.01716.65
7.3.200.0120.00919.39
7.3.190.0130.00616.59
7.3.180.0130.00316.71
7.3.170.0080.00816.52
7.3.160.0100.00716.44
7.3.130.0070.01015.72
7.3.120.0090.00815.48
7.3.110.0050.01015.86
7.3.100.0090.00515.63
7.3.90.0060.00615.86
7.3.80.0080.00615.64
7.3.70.0050.00515.69
7.3.60.0050.01015.70
7.3.50.0070.00615.48
7.3.40.0050.00815.58
7.3.30.0060.00715.66
7.3.20.0080.00817.61
7.3.10.0050.01017.64
7.3.00.0010.01117.69
7.2.330.0100.00716.66
7.2.320.0080.00816.80
7.2.310.0060.01316.67
7.2.300.0080.00916.62
7.2.290.0100.00716.70
7.2.260.0050.01315.96
7.2.250.0030.01216.00
7.2.240.0060.00815.91
7.2.230.0100.00616.07
7.2.220.0070.00415.97
7.2.210.0080.00615.98
7.2.200.0040.00716.02
7.2.190.0100.00515.97
7.2.180.0040.01315.89
7.2.170.0060.00816.04
7.2.160.0030.00815.89
7.2.150.0030.01217.80
7.2.140.0090.00517.75
7.2.130.0020.01117.86
7.2.120.0060.01017.85
7.2.110.0050.00917.68
7.2.100.0060.01017.67
7.2.90.0030.00817.91
7.2.80.0000.01517.68
7.2.70.0100.00517.76
7.2.60.0070.00717.56
7.2.50.0070.00717.59
7.2.40.0070.01017.83
7.2.30.0000.01417.72
7.2.20.0070.00917.75
7.2.10.0080.00817.60
7.2.00.0060.00917.74
7.1.330.0070.00916.71
7.1.320.0080.00516.68
7.1.310.0100.00216.71
7.1.300.0060.00916.85
7.1.290.0030.01116.79
7.1.280.0040.00716.96
7.1.270.0060.00816.60
7.1.260.0070.01016.93
7.1.250.0070.00516.75
7.1.240.0050.00916.71
7.1.230.0090.00816.74
7.1.220.0080.00616.70
7.1.210.0060.00616.51
7.1.200.0060.00616.38
7.1.190.0050.00816.79
7.1.180.0080.00616.85
7.1.170.0060.00816.79
7.1.160.0040.00716.69
7.1.150.0070.00716.66
7.1.140.0050.00916.91
7.1.130.0090.00716.56
7.1.120.0090.00716.54
7.1.110.0060.00516.73
7.1.100.0140.00016.82
7.1.90.0080.00416.79
7.1.80.0000.01316.82
7.1.70.0060.00617.04
7.1.60.0090.00917.66
7.1.50.0060.00716.94
7.1.40.0050.00816.73
7.1.30.0080.00616.76
7.1.20.0080.00716.89
7.1.10.0070.00916.71
7.1.00.0030.03318.59
7.0.330.0060.00816.51
7.0.320.0060.00616.38
7.0.310.0050.00516.39
7.0.300.0040.00716.37
7.0.290.0020.01216.16
7.0.280.0070.00816.25
7.0.270.0080.00716.39
7.0.260.0080.00216.36
7.0.250.0050.00916.37
7.0.240.0050.00816.27
7.0.230.0080.00316.55
7.0.220.0040.00616.18
7.0.210.0020.01216.42
7.0.200.0040.00716.39
7.0.190.0020.00916.38
7.0.180.0060.00816.40
7.0.170.0050.00916.47
7.0.160.0050.00916.34
7.0.150.0050.00716.33
7.0.140.0050.03018.25
7.0.130.0050.00716.36
7.0.120.0050.01116.35
7.0.110.0020.01016.24
7.0.100.0120.03017.66
7.0.90.0080.03417.53
7.0.80.0090.03317.48
7.0.70.0100.02417.61
7.0.60.0090.03217.49
7.0.50.0080.02317.75
7.0.40.0040.03316.25
7.0.30.0060.03416.30
7.0.20.0060.03516.38
7.0.10.0060.03216.31
7.0.00.0080.03016.23
5.6.400.0030.00815.04
5.6.390.0050.00815.30
5.6.380.0090.00115.31
5.6.370.0120.00315.20
5.6.360.0060.00615.14
5.6.350.0070.00514.85
5.6.340.0050.00715.16
5.6.330.0070.00715.22
5.6.320.0060.00815.21
5.6.310.0120.00315.34
5.6.300.0080.00815.19
5.6.290.0100.00814.96
5.6.280.0030.03117.12
5.6.270.0040.01015.17
5.6.260.0070.00715.13
5.6.250.0110.02516.93
5.6.240.0020.03616.92
5.6.230.0060.03417.00
5.6.220.0020.03616.92
5.6.210.0100.03116.90
5.6.200.0060.03317.22
5.6.190.0120.02717.09
5.6.180.0100.03117.11
5.6.170.0130.02817.02
5.6.160.0080.03217.20
5.6.150.0080.03017.11
5.6.140.0100.02917.13
5.6.130.0090.03417.19
5.6.120.0080.02917.09
5.6.110.0090.02617.13
5.6.100.0100.02917.06
5.6.90.0090.02917.22
5.6.80.0050.03116.75
5.6.70.0070.03216.83
5.6.60.0110.02916.94
5.6.50.0080.02716.79
5.6.40.0090.03116.77
5.6.30.0100.03116.91
5.6.20.0050.03216.83
5.6.10.0080.03116.85
5.6.00.0080.02616.86
5.5.380.0080.03116.75
5.5.370.0080.03116.91
5.5.360.0060.03116.86
5.5.350.0110.02416.90
5.5.340.0090.03017.12
5.5.330.0050.02216.86
5.5.320.0100.03117.04
5.5.310.0070.02416.84
5.5.300.0060.03217.00
5.5.290.0020.03816.95
5.5.280.0090.02417.09
5.5.270.0050.03516.90
5.5.260.0050.03116.98
5.5.250.0050.03516.72
5.5.240.0090.02616.73
5.5.230.0060.02716.65
5.5.220.0060.03216.76
5.5.210.0060.03016.61
5.5.200.0040.02316.71
5.5.190.0050.03116.78
5.5.180.0060.03116.65
5.5.170.0040.00915.04
5.5.160.0050.02416.87
5.5.150.0080.03016.52
5.5.140.0090.02616.85
5.5.130.0040.03116.76
5.5.120.0030.02916.85
5.5.110.0050.02616.67
5.5.100.0070.02916.82
5.5.90.0040.03116.58
5.5.80.0070.02816.72
5.5.70.0020.03316.68
5.5.60.0080.02216.61
5.5.50.0060.02916.63
5.5.40.0030.02716.74
5.5.30.0020.01916.53
5.5.20.0040.03316.66
5.5.10.0060.02916.71
5.5.00.0050.03116.62
5.4.450.0090.03114.58
5.4.440.0080.03014.52
5.4.430.0070.02514.56
5.4.420.0080.02414.39
5.4.410.0040.03314.49
5.4.400.0060.02914.37
5.4.390.0070.02914.45
5.4.380.0100.02614.38
5.4.370.0080.02914.46
5.4.360.0040.03014.37
5.4.350.0080.02914.38
5.4.340.0050.02714.43
5.4.330.0080.00512.05
5.4.320.0040.02814.29
5.4.310.0080.03114.40
5.4.300.0030.02314.27
5.4.290.0050.02814.40
5.4.280.0030.02614.25
5.4.270.0070.02614.30
5.4.260.0100.02514.36
5.4.250.0050.02814.43
5.4.240.0030.02914.34
5.4.230.0050.02814.41
5.4.220.0060.01314.38
5.4.210.0010.02614.40
5.4.200.0020.02914.47
5.4.190.0030.03014.40
5.4.180.0090.02614.37
5.4.170.0080.02814.33
5.4.160.0040.02714.38
5.4.150.0060.01514.38
5.4.140.0010.02013.53
5.4.130.0060.02613.46
5.4.120.0050.02613.56
5.4.110.0040.02713.68
5.4.100.0030.02013.61
5.4.90.0040.02413.67
5.4.80.0050.03013.49
5.4.70.0020.02913.53
5.4.60.0090.02413.58
5.4.50.0060.02713.50
5.4.40.0070.03113.54
5.4.30.0060.01613.41
5.4.20.0020.03213.43
5.4.10.0040.02413.44
5.4.00.0030.02813.31
5.3.290.0030.03912.75
5.3.280.0070.03012.81
5.3.270.0070.02312.80
5.3.260.0010.03212.86
5.3.250.0040.01612.79
5.3.240.0030.01612.74
5.3.230.0040.03012.82
5.3.220.0060.02512.72
5.3.210.0050.01512.76
5.3.200.0020.02612.75
5.3.190.0060.02812.81
5.3.180.0060.02512.92
5.3.170.0110.02512.84
5.3.160.0080.01612.85
5.3.150.0050.02612.75
5.3.140.0030.02912.82
5.3.130.0040.03012.78
5.3.120.0040.02812.82
5.3.110.0040.03312.71
5.3.100.0050.02912.64
5.3.90.0050.02812.75
5.3.80.0040.02512.57
5.3.70.0020.02112.51
5.3.60.0060.02912.60
5.3.50.0050.03312.53
5.3.40.0070.02212.56
5.3.30.0070.02012.59
5.3.20.0020.03212.45
5.3.10.0050.02512.42
5.3.00.0060.01712.31
5.2.170.0030.06711.08
5.2.160.0000.07011.29
5.2.150.0070.05311.25
5.2.140.0030.03711.14
5.2.130.0070.03311.09
5.2.120.0030.06011.17
5.2.110.0030.03311.24
5.2.100.0070.06011.02
5.2.90.0070.05711.17
5.2.80.0130.05311.18
5.2.70.0030.06011.13
5.2.60.0030.06011.14
5.2.50.0030.06011.09
5.2.40.0100.05711.11
5.2.30.0070.06310.96
5.2.20.0130.04011.11
5.2.10.0100.04010.88
5.2.00.0000.03710.75
5.1.60.0030.0539.84
5.1.50.0070.05310.04
5.1.40.0130.0479.83
5.1.30.0070.03010.21
5.1.20.0100.05010.49
5.1.10.0030.05310.15
5.1.00.0030.03310.16
5.0.50.0030.0478.66
5.0.40.0000.0408.42
5.0.30.0000.0408.34
5.0.20.0100.0378.07
5.0.10.0030.0338.30
5.0.00.0030.0638.22
4.4.90.0030.0337.81
4.4.80.0030.0337.81
4.4.70.0070.0307.81
4.4.60.0000.0377.81
4.4.50.0100.0277.81
4.4.40.0070.0477.81
4.4.30.0000.0207.81
4.4.20.0030.0337.81
4.4.10.0000.0207.81
4.4.00.0030.0377.81
4.3.110.0030.0237.81
4.3.100.0070.0277.81
4.3.90.0070.0207.81
4.3.80.0000.0337.81
4.3.70.0030.0337.81
4.3.60.0070.0307.81
4.3.50.0000.0307.81
4.3.40.0000.0377.81
4.3.30.0070.0237.81
4.3.20.0100.0307.81
4.3.10.0000.0377.81
4.3.00.0030.0307.81

preferences:
41.01 ms | 400 KiB | 5 Q