3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($number) { if (!IsValidNumber($number)) { throw new \Exception('Invalid phone number'); } echo $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.60.0090.01216.50
8.3.50.0130.00722.05
8.3.40.0150.00018.69
8.3.30.0090.00619.08
8.3.20.0110.00320.38
8.3.10.0040.00423.55
8.3.00.0040.00717.63
8.2.180.0100.01016.60
8.2.170.0150.00022.96
8.2.160.0090.00620.38
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0070.00022.30
8.2.110.0060.00321.13
8.2.100.0070.00717.84
8.2.90.0040.00419.08
8.2.80.0040.00417.97
8.2.70.0030.00617.63
8.2.60.0040.00417.93
8.2.50.0040.00418.07
8.2.40.0030.00618.34
8.2.30.0040.00418.05
8.2.20.0000.00817.81
8.2.10.0030.00517.73
8.2.00.0000.00817.74
8.1.280.0190.00025.92
8.1.270.0090.00023.79
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0070.00322.09
8.1.230.0110.00018.95
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0000.01017.35
8.1.190.0050.00317.35
8.1.180.0040.00418.10
8.1.170.0050.00318.49
8.1.160.0030.00622.02
8.1.150.0000.00718.70
8.1.140.0050.00217.45
8.1.130.0000.00717.83
8.1.120.0000.00717.43
8.1.110.0000.00917.28
8.1.100.0000.00717.48
8.1.90.0000.00717.48
8.1.80.0040.00417.39
8.1.70.0000.00717.39
8.1.60.0030.00617.64
8.1.50.0040.00417.52
8.1.40.0000.00817.55
8.1.30.0040.00417.64
8.1.20.0040.00417.71
8.1.10.0040.00417.46
8.1.00.0000.00817.48
8.0.300.0000.00820.16
8.0.290.0080.00016.75
8.0.280.0000.00718.38
8.0.270.0040.00417.26
8.0.260.0000.00616.88
8.0.250.0060.00017.01
8.0.240.0040.00417.07
8.0.230.0030.00316.97
8.0.220.0070.00017.00
8.0.210.0030.00416.90
8.0.200.0030.00316.98
8.0.190.0050.00317.07
8.0.180.0040.00416.94
8.0.170.0030.00616.94
8.0.160.0070.00016.85
8.0.150.0000.00716.88
8.0.140.0000.00716.88
8.0.130.0030.00613.39
8.0.120.0000.00716.82
8.0.110.0040.00416.92
8.0.100.0030.00317.00
8.0.90.0020.00516.94
8.0.80.0090.00616.91
8.0.70.0000.00716.95
8.0.60.0000.00716.93
8.0.50.0020.00516.93
8.0.30.0110.01017.33
8.0.20.0080.01117.40
8.0.10.0000.00816.95
8.0.00.0150.00716.82
7.4.330.0050.00015.00
7.4.320.0030.00316.52
7.4.300.0030.00316.61
7.4.290.0050.00316.49
7.4.280.0000.00716.63
7.4.270.0000.00716.62
7.4.260.0030.00416.60
7.4.250.0000.01016.39
7.4.240.0040.00416.52
7.4.230.0020.00516.67
7.4.220.0110.00716.54
7.4.210.0110.00416.54
7.4.200.0000.00716.49
7.4.190.0040.00416.61
7.4.160.0040.01216.69
7.4.150.0090.01017.40
7.4.140.0080.01217.86
7.4.130.0030.01416.63
7.4.120.0080.01116.65
7.4.110.0100.00716.46
7.4.100.0120.00616.57
7.4.90.0130.00316.45
7.4.80.0030.01419.39
7.4.70.0070.01516.38
7.4.60.0070.01116.46
7.4.50.0040.00416.44
7.4.40.0070.01122.77
7.4.30.0030.01416.59
7.4.00.0110.00614.82
7.3.330.0030.00313.43
7.3.320.0000.00513.20
7.3.310.0040.00416.32
7.3.300.0040.00416.38
7.3.290.0040.01116.36
7.3.280.0100.00816.37
7.3.270.0080.00817.40
7.3.260.0070.01016.48
7.3.250.0080.00916.28
7.3.240.0090.00916.58
7.3.230.0140.00316.39
7.3.210.0070.01116.61
7.3.200.0130.00719.39
7.3.190.0110.00716.30
7.3.180.0030.01316.38
7.3.170.0090.01116.40
7.3.160.0080.00816.46
7.3.120.0060.00914.98
7.3.10.0110.00516.78
7.3.00.0040.00416.81
7.2.330.0080.01616.76
7.2.320.0030.01316.37
7.2.310.0090.00616.61
7.2.300.0150.00016.68
7.2.290.0120.01216.41
7.2.130.0060.00916.83
7.2.120.0020.00816.91
7.2.110.0030.00816.84
7.2.100.0030.01016.82
7.2.90.0050.00716.82
7.2.80.0060.00616.84
7.2.70.0110.00616.86
7.2.60.0040.00916.80
7.2.50.0050.00816.78
7.2.40.0050.00616.94
7.2.30.0070.00416.86
7.2.20.0080.00616.89
7.2.10.0030.00716.92
7.2.00.0060.00917.51
7.1.250.0070.00515.77
7.1.200.0000.00915.79
7.1.70.0110.00817.19
7.1.60.0000.01017.28
7.1.50.0060.01017.01
7.1.00.0000.07722.27
7.0.200.0130.00316.85
7.0.140.0030.07321.95
7.0.120.0070.06722.00
7.0.110.0030.07322.12
7.0.100.0070.06322.04
7.0.90.0000.04022.14
7.0.80.0070.05722.03
7.0.70.0130.06322.01
7.0.60.0070.06721.95
7.0.50.0030.04722.03
7.0.40.0130.05720.03
7.0.30.0030.06020.13
7.0.20.0000.06320.01
7.0.10.0030.04320.07
7.0.00.0070.05720.11
5.6.280.0030.07321.00
5.6.270.0100.07720.83
5.6.260.0100.04321.03
5.6.250.0070.04021.05
5.6.240.0000.08720.79
5.6.230.0070.07321.04
5.6.220.0100.07020.82
5.6.210.0030.07020.91
5.6.200.0070.06320.79
5.6.190.0030.08021.02
5.6.180.0030.07721.04
5.6.170.0170.03720.89
5.6.160.0070.05720.75
5.6.150.0070.07020.98
5.6.140.0030.08320.96
5.6.130.0070.08321.04
5.6.120.0030.04720.95
5.6.110.0000.05720.97
5.6.100.0100.04720.94
5.6.90.0030.04720.87
5.6.80.0030.04320.27
5.6.70.0100.07320.18
5.6.60.0030.04720.36
5.6.50.0070.04020.25
5.6.40.0070.08020.07
5.6.30.0170.07020.13
5.6.20.0030.04020.32
5.6.10.0100.07320.39
5.6.00.0000.06020.14
5.5.380.0100.08017.55
5.5.370.0030.07717.54
5.5.360.0070.04317.55
5.5.350.0100.07017.50
5.5.340.0070.06717.93
5.5.330.0030.04317.93
5.5.320.0100.07718.25
5.5.310.0030.04017.91
5.5.300.0030.08718.08
5.5.290.0130.08018.10
5.5.280.0030.08318.05
5.5.270.0000.05717.95
5.5.260.0070.06318.08
5.5.250.0030.07317.73
5.5.240.0100.03717.57
5.5.230.0030.08017.29
5.5.220.0130.08017.48
5.5.210.0130.06017.47
5.5.200.0000.08317.19
5.5.190.0070.07017.30
5.5.180.0000.08017.41
5.5.160.0000.05717.58
5.5.150.0130.07317.47
5.5.140.0070.03717.48
5.5.130.0000.04017.42
5.5.120.0000.04717.30
5.5.110.0030.07717.27
5.5.100.0070.03017.17
5.5.90.0030.07717.18
5.5.80.0000.04017.33
5.5.70.0070.08017.17
5.5.60.0100.07017.33
5.5.50.0070.07317.33
5.5.40.0000.05017.46
5.5.30.0030.06717.50
5.5.20.0000.05317.32
5.5.10.0070.05017.16
5.5.00.0070.03317.16
5.4.450.0070.08019.54
5.4.440.0070.07319.28
5.4.430.0000.05719.51
5.4.420.0100.07719.36
5.4.410.0100.03719.16
5.4.400.0070.07019.13
5.4.390.0070.03718.98
5.4.380.0000.04719.13
5.4.370.0030.04019.09
5.4.360.0030.05719.11
5.4.350.0100.05018.96
5.4.340.0100.04319.04
5.4.320.0030.06019.28
5.4.310.0030.04319.19
5.4.300.0070.07019.09
5.4.290.0100.06719.13
5.4.280.0030.07319.10
5.4.270.0030.07319.18
5.4.260.0100.07319.09
5.4.250.0030.05719.12
5.4.240.0030.04019.21
5.4.230.0070.07019.18
5.4.220.0030.07718.93
5.4.210.0070.03018.91
5.4.200.0030.03318.91
5.4.190.0070.06719.20
5.4.180.0070.07719.23
5.4.170.0070.03719.03
5.4.160.0000.04018.93
5.4.150.0030.04718.90
5.4.140.0070.08016.61
5.4.130.0030.06016.34
5.4.120.0030.05016.36
5.4.110.0070.06016.42
5.4.100.0000.04716.56
5.4.90.0130.02716.46
5.4.80.0070.06716.56
5.4.70.0000.04316.42
5.4.60.0030.04716.47
5.4.50.0070.05316.58
5.4.40.0070.02716.54
5.4.30.0030.07316.46
5.4.20.0000.03316.45
5.4.10.0030.03316.34
5.4.00.0070.05015.77
5.3.290.0000.08014.63
5.3.280.0030.07714.63
5.3.270.0070.06014.63
5.3.260.0100.04714.57
5.3.250.0100.05014.47
5.3.240.0100.04014.60
5.3.230.0030.03714.73
5.3.220.0070.07314.59
5.3.210.0170.03714.66
5.3.200.0000.03714.80
5.3.190.0070.04014.68
5.3.180.0070.03314.57
5.3.170.0000.04014.58
5.3.160.0100.02314.58
5.3.150.0070.03014.55
5.3.140.0000.03714.57
5.3.130.0070.04014.57
5.3.120.0070.02714.56
5.3.110.0070.03314.41
5.3.100.0070.07014.06
5.3.90.0030.06014.07
5.3.80.0000.07314.04
5.3.70.0070.05714.04
5.3.60.0100.07314.08
5.3.50.0100.07013.95
5.3.40.0030.05713.97
5.3.30.0030.08713.99
5.3.20.0030.06013.77
5.3.10.0100.05713.79
5.3.00.0030.03713.66
5.2.170.0000.03711.24
5.2.160.0070.03711.13
5.2.150.0030.06711.21
5.2.140.0000.04711.21
5.2.130.0000.03011.17
5.2.120.0030.07011.11
5.2.110.0000.02711.10
5.2.100.0030.04311.23
5.2.90.0070.02011.19
5.2.80.0000.05011.09
5.2.70.0030.03011.11
5.2.60.0070.02311.03
5.2.50.0000.03310.98
5.2.40.0070.06011.13
5.2.30.0030.03011.21
5.2.20.0000.03011.10
5.2.10.0000.03010.88
5.2.00.0000.03010.74
5.1.60.0100.0179.95
5.1.50.0030.02310.02
5.1.40.0000.0209.96
5.1.30.0000.02710.34
5.1.20.0030.02010.38
5.1.10.0000.02710.07
5.1.00.0000.02010.09
5.0.50.0030.0239.81
5.0.40.0000.0179.81
5.0.30.0000.0339.81
5.0.20.0000.0179.81
5.0.10.0030.0309.81
5.0.00.0000.0309.81
4.4.90.0100.0279.81
4.4.80.0030.0279.81
4.4.70.0000.0139.81
4.4.60.0000.0179.81
4.4.50.0000.0139.81
4.4.40.0000.0209.81
4.4.30.0000.0139.81
4.4.20.0030.0139.81
4.4.10.0000.0179.81
4.4.00.0000.0439.81
4.3.110.0030.0279.81
4.3.100.0000.0309.81
4.3.90.0000.0179.81
4.3.80.0030.0239.81
4.3.70.0000.0239.81
4.3.60.0000.0179.81
4.3.50.0000.0179.81
4.3.40.0000.0239.81
4.3.30.0030.0139.81
4.3.20.0000.0479.81
4.3.10.0000.0179.81
4.3.00.0000.0179.81

preferences:
49.49 ms | 400 KiB | 5 Q