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) { var_dump(is_numeric($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.0170.00016.25
8.3.50.0030.01621.08
8.3.40.0130.00318.48
8.3.30.0040.01118.67
8.3.20.0050.00318.60
8.3.10.0040.00420.58
8.3.00.0050.00323.53
8.2.180.0150.00016.38
8.2.170.0120.00822.96
8.2.160.0110.00720.40
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0000.00726.16
8.2.120.0000.00819.38
8.2.110.0060.00321.00
8.2.100.0080.00417.59
8.2.90.0030.00619.22
8.2.80.0090.00017.97
8.2.70.0060.00317.50
8.2.60.0030.00517.80
8.2.50.0050.00318.07
8.2.40.0040.00418.22
8.2.30.0040.00419.85
8.2.20.0040.00417.56
8.2.10.0040.00419.47
8.2.00.0030.00617.58
8.1.280.0040.01425.92
8.1.270.0040.00423.99
8.1.260.0110.00726.35
8.1.250.0040.00428.09
8.1.240.0000.00921.37
8.1.230.0090.00317.42
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0090.00017.11
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0040.00418.43
8.1.160.0020.00518.91
8.1.150.0000.00818.71
8.1.140.0030.00617.59
8.1.130.0000.00817.89
8.1.120.0040.00417.52
8.1.110.0000.00717.44
8.1.100.0020.00517.46
8.1.90.0040.00417.48
8.1.80.0070.00017.51
8.1.70.0030.00317.45
8.1.60.0030.00617.50
8.1.50.0040.00417.43
8.1.40.0050.00217.48
8.1.30.0000.00717.65
8.1.20.0040.00417.67
8.1.10.0030.00517.44
8.1.00.0030.00617.41
8.0.300.0030.00518.77
8.0.290.0070.00016.75
8.0.280.0000.00718.48
8.0.270.0070.00017.28
8.0.260.0030.00516.76
8.0.250.0040.00416.97
8.0.240.0000.00816.86
8.0.230.0070.00016.91
8.0.220.0060.00016.94
8.0.210.0050.00216.92
8.0.200.0030.00316.95
8.0.190.0040.00416.86
8.0.180.0070.00016.83
8.0.170.0050.00216.82
8.0.160.0000.00716.91
8.0.150.0030.00716.87
8.0.140.0050.00316.89
8.0.130.0030.00613.41
8.0.120.0000.00816.86
8.0.110.0040.00416.81
8.0.100.0030.00516.86
8.0.90.0000.00716.91
8.0.80.0060.00916.95
8.0.70.0070.00016.88
8.0.60.0000.00716.70
8.0.50.0000.00716.94
8.0.30.0120.01017.09
8.0.20.0060.01317.40
8.0.10.0040.00417.07
8.0.00.0140.00816.63
7.4.330.0050.00013.43
7.4.320.0060.00016.53
7.4.300.0000.00616.52
7.4.290.0070.00016.57
7.4.280.0030.00616.67
7.4.270.0030.00316.63
7.4.260.0050.00013.41
7.4.250.0060.00316.48
7.4.240.0030.00316.40
7.4.230.0030.00616.73
7.4.220.0060.01016.63
7.4.210.0050.01016.63
7.4.200.0050.00216.64
7.4.190.0080.00016.58
7.4.160.0100.01316.37
7.4.150.0120.00617.40
7.4.140.0070.01017.86
7.4.130.0130.00716.61
7.4.120.0060.01116.43
7.4.110.0090.00916.44
7.4.100.0150.00416.71
7.4.90.0190.00816.60
7.4.80.0090.00819.37
7.4.70.0130.00316.39
7.4.60.0090.00816.53
7.4.50.0000.00816.37
7.4.40.0110.00822.27
7.4.30.0100.00716.50
7.4.10.0130.00714.80
7.4.00.0070.01214.92
7.3.330.0000.00513.25
7.3.320.0030.00313.20
7.3.310.0000.00716.29
7.3.300.0000.00716.38
7.3.290.0060.00916.36
7.3.280.0050.01016.38
7.3.270.0110.00617.40
7.3.260.0160.00118.24
7.3.250.0090.00916.56
7.3.240.0100.00616.31
7.3.230.0140.00616.39
7.3.210.0090.00916.69
7.3.200.0150.00819.39
7.3.190.0110.00716.34
7.3.180.0000.01716.38
7.3.170.0130.00316.52
7.3.160.0060.01116.38
7.3.130.0000.01614.60
7.3.120.0130.00414.84
7.3.110.0030.01714.85
7.3.100.0000.01114.96
7.3.90.0000.01514.90
7.3.80.0000.01414.62
7.3.70.0130.00315.00
7.3.60.0060.00814.70
7.3.50.0000.01614.71
7.3.40.0070.00714.92
7.3.30.0070.00714.93
7.3.20.0090.00616.85
7.3.10.0090.00616.77
7.3.00.0090.00016.67
7.2.330.0090.00916.41
7.2.320.0040.01216.65
7.2.310.0070.01316.80
7.2.300.0030.01416.44
7.2.290.0130.00616.50
7.2.260.0090.00314.86
7.2.250.0070.01315.13
7.2.240.0060.00915.00
7.2.230.0080.00415.04
7.2.220.0040.01115.21
7.2.210.0030.00714.87
7.2.200.0100.00614.95
7.2.190.0070.01014.97
7.2.180.0100.00315.09
7.2.170.0060.00914.92
7.2.160.0000.01415.07
7.2.150.0030.01216.83
7.2.140.0080.00616.97
7.2.130.0030.00616.73
7.2.120.0090.00617.02
7.2.110.0060.00316.90
7.2.100.0000.01116.88
7.2.90.0040.01116.80
7.2.80.0060.01316.98
7.2.70.0080.00416.72
7.2.60.0040.01117.03
7.2.50.0070.00716.84
7.2.40.0040.01116.63
7.2.30.0040.00716.98
7.2.20.0080.00817.09
7.2.10.0040.01416.72
7.2.00.0080.00816.73
7.1.330.0030.01015.83
7.1.320.0080.00315.86
7.1.310.0000.01315.71
7.1.300.0070.01015.88
7.1.290.0030.00715.80
7.1.280.0040.00415.73
7.1.270.0030.00615.88
7.1.260.0050.00515.97
7.1.250.0100.00616.05
7.1.240.0070.00715.98
7.1.230.0040.00715.60
7.1.220.0060.00615.68
7.1.210.0030.00815.92
7.1.200.0040.01115.68
7.1.190.0030.00815.55
7.1.180.0000.01215.75
7.1.170.0040.01115.83
7.1.160.0070.00715.95
7.1.150.0030.00615.78
7.1.140.0080.00415.60
7.1.130.0030.00615.71
7.1.120.0100.00315.85
7.1.110.0070.00715.90
7.1.100.0030.01015.95
7.1.90.0040.00416.02
7.1.80.0090.00316.02
7.1.70.0050.00416.41
7.1.60.0050.01117.61
7.1.50.0040.01316.55
7.1.40.0070.00715.91
7.1.30.0060.00315.86
7.1.20.0030.01015.84
7.1.10.0090.00615.89
7.1.00.0050.04119.08
7.0.330.0100.00315.61
7.0.320.0100.00315.54
7.0.310.0060.00915.38
7.0.300.0100.00315.55
7.0.290.0070.00315.40
7.0.280.0040.00415.04
7.0.270.0040.00415.64
7.0.260.0120.00315.41
7.0.250.0000.00915.39
7.0.240.0120.00315.40
7.0.230.0030.00715.38
7.0.220.0030.00915.43
7.0.210.0030.00615.52
7.0.200.0130.01115.17
7.0.190.0000.01315.52
7.0.180.0060.00915.39
7.0.170.0000.00815.55
7.0.160.0090.00315.30
7.0.150.0060.00915.16
7.0.140.0040.03918.62
7.0.130.0040.00815.61
7.0.120.0030.01015.58
7.0.110.0100.00015.54
7.0.100.0070.00715.16
7.0.90.0160.00015.62
7.0.80.0000.01415.41
7.0.70.0080.00415.52
7.0.60.0070.04717.81
7.0.50.0050.04416.75
7.0.40.0040.02915.52
7.0.30.0100.03515.63
7.0.20.0050.04615.57
7.0.10.0050.04415.66
7.0.00.0020.05015.63
5.6.400.0040.00814.62
5.6.390.0060.00614.63
5.6.380.0030.01214.23
5.6.370.0030.01014.56
5.6.360.0070.00714.30
5.6.350.0000.01514.50
5.6.340.0090.00314.32
5.6.330.0070.00414.45
5.6.320.0070.00714.59
5.6.310.0060.00314.66
5.6.300.0070.00714.26
5.6.290.0080.00014.58
5.6.280.0070.03717.59
5.6.270.0100.00014.26
5.6.260.0050.00514.34
5.6.250.0090.00914.11
5.6.240.0030.01314.26
5.6.230.0000.00914.39
5.6.220.0030.00514.27
5.6.210.0080.04317.39
5.6.200.0020.04616.27
5.6.190.0050.02816.30
5.6.180.0070.03816.19
5.6.170.0040.04016.31
5.6.160.0090.04216.14
5.6.150.0030.04616.44
5.6.140.0060.04316.31
5.6.130.0050.03416.27
5.6.120.0080.03016.22
5.6.110.0030.04516.22
5.6.100.0060.03816.41
5.6.90.0110.03316.24
5.6.80.0080.04015.94
5.6.70.0050.04615.93
5.6.60.0050.02215.91
5.6.50.0050.04315.97
5.6.40.0090.04315.83
5.6.30.0060.02315.94
5.6.20.0060.02516.01
5.6.10.0050.02415.91
5.6.00.0090.02015.99
5.5.380.0000.01514.38
5.5.370.0000.01214.23
5.5.360.0070.00713.98
5.5.350.0170.04017.35
5.5.340.0030.02716.10
5.5.330.0020.02916.15
5.5.320.0030.03216.13
5.5.310.0050.04316.28
5.5.300.0060.04216.10
5.5.290.0040.04116.00
5.5.280.0050.03115.96
5.5.270.0110.04116.21
5.5.260.0150.03716.09
5.5.250.0080.04216.08
5.5.240.0070.03715.79
5.5.230.0050.02615.66
5.5.220.0020.04015.83
5.5.210.0100.02915.77
5.5.200.0050.04215.82
5.5.190.0060.03615.73
5.5.180.0050.02715.75
5.5.170.0030.01014.28
5.5.160.0060.03915.86
5.5.150.0060.02015.80
5.5.140.0060.02815.85
5.5.130.0030.02215.89
5.5.120.0060.02115.82
5.5.110.0040.02115.79
5.5.100.0030.02115.78
5.5.90.0040.02415.80
5.5.80.0090.01815.84
5.5.70.0030.02915.62
5.5.60.0060.02115.72
5.5.50.0040.02415.79
5.5.40.0030.02315.75
5.5.30.0050.02315.66
5.5.20.0050.02215.81
5.5.10.0050.02315.79
5.5.00.0020.02315.81
5.4.450.0050.04215.98
5.4.440.0120.02316.01
5.4.430.0120.03515.97
5.4.420.0090.03515.97
5.4.410.0100.04015.97
5.4.400.0100.03515.83
5.4.390.0110.03015.79
5.4.380.0080.03615.83
5.4.370.0040.04415.83
5.4.360.0070.02315.79
5.4.350.0050.02915.74
5.4.340.0020.03615.81
5.4.330.0060.00612.60
5.4.320.0020.03415.87
5.4.310.0050.02615.85
5.4.300.0080.01715.74
5.4.290.0030.02315.83
5.4.280.0010.02415.78
5.4.270.0030.02215.80
5.4.260.0020.02315.81
5.4.250.0050.02015.78
5.4.240.0030.02015.87
5.4.230.0050.02115.74
5.4.220.0020.02115.81
5.4.210.0050.01915.87
5.4.200.0010.02615.94
5.4.190.0080.01815.82
5.4.180.0080.01815.86
5.4.170.0030.02015.93
5.4.160.0040.02015.81
5.4.150.0010.02615.86
5.4.140.0030.01814.49
5.4.130.0030.02014.53
5.4.120.0030.02014.51
5.4.110.0030.02014.48
5.4.100.0030.02214.55
5.4.90.0000.02514.60
5.4.80.0020.02014.54
5.4.70.0050.02014.54
5.4.60.0030.02214.50
5.4.50.0020.02314.44
5.4.40.0030.02214.54
5.4.30.0020.02314.58
5.4.20.0030.04214.52
5.4.10.0050.01914.45
5.4.00.0020.04514.14
5.3.290.0060.03613.56
5.3.280.0080.01513.53
5.3.270.0060.01613.63
5.3.260.0020.02513.63
5.3.250.0000.02313.53
5.3.240.0060.02313.62
5.3.230.0050.02013.64
5.3.220.0030.02013.59
5.3.210.0090.01513.62
5.3.200.0000.02513.70
5.3.190.0000.03213.57
5.3.180.0040.02213.61
5.3.170.0070.01913.62
5.3.160.0050.02413.61
5.3.150.0040.02213.58
5.3.140.0120.01313.58
5.3.130.0050.02013.59
5.3.120.0040.03013.59
5.3.110.0050.04213.60
5.3.100.0080.03713.35
5.3.90.0070.03313.34
5.3.80.0040.04013.31
5.3.70.0080.02713.30
5.3.60.0070.03313.31
5.3.50.0050.02913.27
5.3.40.0090.03313.38
5.3.30.0070.03313.29
5.3.20.0050.03713.15
5.3.10.0070.03913.15
5.3.00.0060.04113.15
5.2.170.0070.06011.25
5.2.160.0030.05311.00
5.2.150.0000.06711.12
5.2.140.0000.07011.05
5.2.130.0030.06011.12
5.2.120.0170.05311.07
5.2.110.0070.05711.16
5.2.100.0030.05711.21
5.2.90.0100.05711.00
5.2.80.0100.06011.13
5.2.70.0100.05311.16
5.2.60.0030.06311.04
5.2.50.0070.04311.02
5.2.40.0070.05311.21
5.2.30.0100.05710.97
5.2.20.0130.05010.96
5.2.10.0030.04010.96
5.2.00.0030.03010.73
5.1.60.0030.02310.11
5.1.50.0100.0479.93
5.1.40.0070.0279.98
5.1.30.0030.02710.38
5.1.20.0000.06010.39
5.1.10.0000.06010.11
5.1.00.0030.05310.11
5.0.50.0000.0538.75
5.0.40.0030.0478.49
5.0.30.0030.0678.27
5.0.20.0030.0378.24
5.0.10.0030.0438.23
5.0.00.0000.0408.15
4.4.90.0000.0377.97
4.4.80.0030.0337.97
4.4.70.0000.0377.97
4.4.60.0070.0307.97
4.4.50.0070.0237.97
4.4.40.0000.0307.97
4.4.30.0000.0177.97
4.4.20.0000.0307.97
4.4.10.0000.0277.97
4.4.00.0000.0577.97
4.3.110.0030.0337.97
4.3.100.0000.0337.97
4.3.90.0000.0237.97
4.3.80.0030.0507.97
4.3.70.0030.0337.97
4.3.60.0000.0377.97
4.3.50.0000.0337.97
4.3.40.0000.0507.97
4.3.30.0000.0407.97
4.3.20.0000.0307.97
4.3.10.0000.0277.97
4.3.00.0000.0307.97

preferences:
43.24 ms | 401 KiB | 5 Q