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.40.0070.01018.93
8.3.30.0110.00318.80
8.3.20.0070.00418.89
8.3.10.0060.00320.70
8.3.00.0090.00019.26
8.2.170.0090.00618.83
8.2.160.0150.00322.96
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0090.00019.48
8.2.110.0000.00922.30
8.2.100.0100.00317.97
8.2.90.0030.00617.75
8.2.80.0040.00417.97
8.2.70.0040.00418.04
8.2.60.0080.00018.03
8.2.50.0000.00818.10
8.2.40.0070.00019.47
8.2.30.0040.00419.16
8.2.20.0000.00717.73
8.2.10.0000.00817.74
8.2.00.0000.00817.87
8.1.270.0080.00023.99
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0030.00718.57
8.1.230.0080.00418.98
8.1.220.0000.00717.74
8.1.210.0050.00318.77
8.1.200.0090.00017.25
8.1.190.0030.00517.35
8.1.180.0000.00718.10
8.1.170.0050.00318.70
8.1.160.0040.00418.89
8.1.150.0040.00418.94
8.1.140.0000.00717.50
8.1.130.0030.00317.74
8.1.120.0060.00317.42
8.1.110.0030.00617.46
8.1.100.0040.00417.43
8.1.90.0000.00717.40
8.1.80.0040.00417.43
8.1.70.0030.00317.34
8.1.60.0040.00417.60
8.1.50.0030.00617.41
8.1.40.0080.00017.55
8.1.30.0040.00417.69
8.1.20.0000.00717.66
8.1.10.0000.00717.52
8.1.00.0040.00417.52
8.0.300.0080.00018.77
8.0.290.0040.00416.88
8.0.280.0000.00718.35
8.0.270.0000.00717.30
8.0.260.0070.00016.79
8.0.250.0040.00416.89
8.0.240.0000.00716.98
8.0.230.0040.00217.05
8.0.220.0030.00616.98
8.0.210.0030.00316.89
8.0.200.0060.00016.93
8.0.190.0050.00216.99
8.0.180.0040.00417.04
8.0.170.0030.00516.97
8.0.160.0000.00716.93
8.0.150.0000.00816.88
8.0.140.0000.00816.95
8.0.130.0000.00513.39
8.0.120.0040.00416.90
8.0.110.0070.00016.93
8.0.100.0040.00416.81
8.0.90.0040.00416.98
8.0.80.0100.01016.89
8.0.70.0040.00416.93
8.0.60.0040.00416.93
8.0.50.0040.00417.02
8.0.30.0120.00916.90
8.0.20.0140.00616.96
8.0.10.0030.00517.07
8.0.00.0080.01016.88
7.4.330.0030.00312.90
7.4.320.0000.00716.52
7.4.300.0060.00016.49
7.4.290.0040.00416.61
7.4.280.0000.00816.58
7.4.270.0050.00216.53
7.4.260.0000.00713.39
7.4.250.0000.00816.54
7.4.240.0040.00416.63
7.4.230.0030.00316.61
7.4.220.0140.00616.49
7.4.210.0090.00716.64
7.4.200.0060.00316.34
7.4.190.0000.00716.77
7.4.160.0090.00616.29
7.4.150.0140.00316.64
7.4.140.0070.01716.45
7.4.130.0090.01016.61
7.4.120.0110.01016.60
7.4.110.0120.00616.61
7.4.100.0090.01516.50
7.4.90.0070.01016.61
7.4.80.0080.00819.39
7.4.70.0130.00616.60
7.4.60.0050.01716.43
7.4.50.0030.00616.32
7.4.40.0110.00316.45
7.4.30.0170.00016.51
7.4.10.0100.00314.83
7.4.00.0070.01014.87
7.3.330.0030.00313.19
7.3.320.0000.00613.43
7.3.310.0030.00316.22
7.3.300.0030.00316.33
7.3.290.0070.01416.33
7.3.280.0060.01116.40
7.3.270.0070.01016.33
7.3.260.0180.00816.47
7.3.250.0090.00716.59
7.3.240.0090.00616.62
7.3.230.0120.00616.42
7.3.210.0100.00716.51
7.3.200.0030.01316.65
7.3.190.0120.00616.52
7.3.180.0060.01016.39
7.3.170.0090.00916.54
7.3.160.0060.01116.54
7.3.130.0030.01314.53
7.3.120.0070.00814.77
7.3.110.0030.01614.90
7.3.100.0060.00614.82
7.3.90.0000.01514.97
7.3.80.0080.00614.80
7.3.70.0070.00714.59
7.3.60.0060.00614.91
7.3.50.0070.00714.73
7.3.40.0000.01114.97
7.3.30.0030.00914.65
7.3.20.0040.01116.73
7.3.10.0060.00616.45
7.3.00.0080.00616.65
7.2.330.0140.01116.70
7.2.320.0070.01016.46
7.2.310.0300.01416.70
7.2.300.0120.00916.65
7.2.290.0060.01116.80
7.2.260.0030.01615.01
7.2.250.0100.01015.20
7.2.240.0060.00915.09
7.2.230.0030.01015.21
7.2.220.0120.00015.33
7.2.210.0000.01514.72
7.2.200.0090.00014.86
7.2.190.0090.00615.07
7.2.180.0030.00714.80
7.2.170.0060.00614.91
7.2.160.0000.01614.72
7.2.150.0040.00816.71
7.2.140.0060.00916.99
7.2.130.0090.00716.92
7.2.120.0060.00916.94
7.2.110.0090.00616.70
7.2.100.0030.01016.97
7.2.90.0030.00816.90
7.2.80.0040.01116.98
7.2.70.0040.00916.82
7.2.60.0050.00716.90
7.2.50.0050.00916.93
7.2.40.0070.00916.96
7.2.30.0040.00716.90
7.2.20.0070.00817.00
7.2.10.0020.01216.87
7.2.00.0030.01117.66
7.1.330.0000.01516.04
7.1.320.0030.00715.39
7.1.310.0060.00615.73
7.1.300.0080.00415.54
7.1.290.0060.00315.94
7.1.280.0000.01215.89
7.1.270.0070.00715.78
7.1.260.0000.01215.55
7.1.250.0060.00615.80
7.1.240.0030.01215.65
7.1.230.0100.00715.89
7.1.220.0060.00515.71
7.1.210.0030.01015.62
7.1.200.0050.00815.69
7.1.190.0050.00815.69
7.1.180.0020.01115.74
7.1.170.0060.00815.83
7.1.160.0030.01015.71
7.1.150.0060.00715.57
7.1.140.0030.01015.74
7.1.130.0060.00515.88
7.1.120.0030.00815.73
7.1.110.0090.00315.79
7.1.100.0070.00916.56
7.1.90.0040.00715.63
7.1.80.0040.00815.84
7.1.70.0060.00716.08
7.1.60.0080.00916.93
7.1.50.0040.01116.11
7.1.40.0020.01015.77
7.1.30.0020.00715.77
7.1.20.0030.00915.63
7.1.10.0050.01015.60
7.1.00.0070.02917.99
7.0.330.0100.00415.26
7.0.320.0020.00715.38
7.0.310.0080.00415.27
7.0.300.0040.00915.35
7.0.290.0040.00715.46
7.0.280.0060.00615.39
7.0.270.0030.00615.15
7.0.260.0030.01015.25
7.0.250.0050.00715.36
7.0.240.0040.01015.41
7.0.230.0050.00915.39
7.0.220.0020.01215.52
7.0.210.0080.00515.26
7.0.200.0110.01015.07
7.0.190.0030.00615.55
7.0.180.0050.00815.46
7.0.170.0040.00815.29
7.0.160.0070.00215.39
7.0.150.0070.00615.36
7.0.140.0070.02617.63
7.0.130.0050.00815.41
7.0.120.0090.01717.67
7.0.110.0030.00815.31
7.0.100.0050.00815.35
7.0.90.0070.00815.34
7.0.80.0050.00715.30
7.0.70.0050.00815.36
7.0.60.0040.02316.91
7.0.50.0110.02916.29
7.0.40.0010.03715.76
7.0.30.0080.01915.68
7.0.20.0150.02815.62
7.0.10.0130.03315.72
7.0.00.0080.03315.74
5.6.400.0040.00414.24
5.6.390.0000.01014.27
5.6.380.0060.00814.23
5.6.370.0040.00714.47
5.6.360.0080.00614.21
5.6.350.0050.00714.25
5.6.340.0020.01014.35
5.6.330.0070.00914.27
5.6.320.0060.00814.39
5.6.310.0050.01114.30
5.6.300.0000.01414.17
5.6.290.0060.00614.27
5.6.280.0060.02616.57
5.6.270.0070.00514.18
5.6.260.0060.00614.42
5.6.250.0030.00914.29
5.6.240.0050.01014.25
5.6.230.0060.00614.27
5.6.220.0030.00614.42
5.6.210.0060.02116.48
5.6.200.0040.01815.73
5.6.190.0050.03316.46
5.6.180.0140.02716.19
5.6.170.0110.01916.27
5.6.160.0110.02916.30
5.6.150.0050.02915.58
5.6.140.0060.02915.60
5.6.130.0030.02215.62
5.6.120.0040.03616.54
5.6.110.0060.01816.50
5.6.100.0080.03016.69
5.6.90.0060.02816.46
5.6.80.0080.03016.31
5.6.70.1490.01716.31
5.6.60.0080.00414.30
5.6.50.0050.00414.21
5.6.40.0030.01114.38
5.6.30.0060.00414.13
5.6.20.0020.01014.17
5.6.10.0070.00714.29
5.6.00.0060.00514.22
5.5.380.0070.00412.77
5.5.370.0040.00712.70
5.5.360.0050.00612.63
5.5.350.0080.01915.38
5.5.340.0040.02814.41
5.5.330.0080.02715.09
5.5.320.0060.02015.28
5.5.310.0120.02915.32
5.5.300.0060.03414.54
5.5.290.0030.02114.35
5.5.280.0050.03115.59
5.5.270.0070.02515.44
5.5.260.0070.02915.35
5.5.250.0070.02915.29
5.5.240.0110.02415.18
5.5.230.0010.00812.70
5.5.220.0070.00412.54
5.5.210.0040.00612.77
5.5.200.0050.00712.63
5.5.190.0030.01012.67
5.5.180.0010.01212.76
5.5.170.0040.01012.74
5.5.160.0040.00712.62
5.5.150.0000.01112.65
5.5.140.0060.00512.40
5.5.130.0070.00312.50
5.5.120.0080.00512.72
5.5.110.0050.00712.66
5.5.100.0050.00612.64
5.5.90.0050.00812.70
5.5.80.0020.00812.67
5.5.70.0060.00312.89
5.5.60.0090.00512.62
5.5.50.0060.00612.52
5.5.40.0030.01112.64
5.5.30.0060.00512.65
5.5.20.0030.00812.75
5.5.10.0030.00612.58
5.5.00.0080.00312.67
5.4.450.0010.02213.77
5.4.440.0050.01713.92
5.4.430.0040.01713.91
5.4.420.0010.02113.94
5.4.410.0030.01613.95
5.4.400.0040.01613.88
5.4.390.0040.01813.80
5.4.380.0020.01813.64
5.4.370.0030.01713.61
5.4.360.0020.01813.72
5.4.350.0040.01413.75
5.4.340.0050.01313.71
5.4.330.0050.00511.00
5.4.320.0050.01513.81
5.4.310.0080.01413.81
5.4.300.0020.02913.71
5.4.290.0050.02513.69
5.4.280.0040.03013.74
5.4.270.0030.03113.56
5.4.260.0030.01713.60
5.4.250.0050.02813.63
5.4.240.0050.02413.79
5.4.230.0070.02413.76
5.4.220.0050.02913.91
5.4.210.0050.02313.80
5.4.200.0050.03013.71
5.4.190.0080.02713.71
5.4.180.0020.02113.76
5.4.170.0050.02913.69
5.4.160.0070.01713.73
5.4.150.0070.02713.63
5.4.140.0030.02112.96
5.4.130.0070.02312.83
5.4.120.0010.02112.88
5.4.110.0080.02612.90
5.4.100.0030.02512.84
5.4.90.0040.02112.94
5.4.80.0010.02512.85
5.4.70.0050.02412.92
5.4.60.0100.01612.96
5.4.50.0020.01812.83
5.4.40.0030.02812.83
5.4.30.0060.02612.76
5.4.20.0040.01912.88
5.4.10.0030.03212.89
5.4.00.0020.03112.66
5.3.290.0030.01612.18
5.3.280.0060.02212.08
5.3.270.0050.02911.99
5.3.260.0040.02812.07
5.3.250.0060.01612.09
5.3.240.0010.02412.03
5.3.230.0090.02011.96
5.3.220.0020.01812.02
5.3.210.0030.03211.96
5.3.200.0020.01912.03
5.3.190.0050.01612.06
5.3.180.0070.02312.07
5.3.170.0070.02712.09
5.3.160.0080.02512.18
5.3.150.0030.02312.11
5.3.140.0060.02312.12
5.3.130.0030.02812.07
5.3.120.0080.02412.04
5.3.110.0040.01912.06
5.3.100.0080.02911.89
5.3.90.0060.02811.94
5.3.80.0060.02211.90
5.3.70.0020.02211.77
5.3.60.0040.03111.86
5.3.50.0060.02511.84
5.3.40.0020.03011.82
5.3.30.0040.03011.80
5.3.20.0070.01411.71
5.3.10.0020.02611.67
5.3.00.0070.02811.72
5.2.170.0030.03511.11
5.2.160.0040.02011.04
5.2.150.0040.03411.11
5.2.140.0020.03711.10
5.2.130.0010.03511.03
5.2.120.0050.02211.09
5.2.110.0040.02111.02
5.2.100.0030.03211.03
5.2.90.0080.02811.03
5.2.80.0060.02111.08
5.2.70.0050.03311.03
5.2.60.0060.03111.03
5.2.50.0050.03011.02
5.2.40.0050.03110.96
5.2.30.0050.03010.99
5.2.20.0020.03411.06
5.2.10.0030.02810.96
5.2.00.0030.02510.88
5.1.60.0080.02310.59
5.1.50.0020.01910.50
5.1.40.0050.02810.48
5.1.30.0030.02010.62
5.1.20.0030.01610.73
5.1.10.0050.01610.62
5.1.00.0070.01310.61
5.0.50.0020.0209.78
5.0.40.0020.0239.70
5.0.30.0040.0249.64
5.0.20.0020.0249.61
5.0.10.0000.0199.60
5.0.00.0020.0329.60
4.4.90.0070.0159.60
4.4.80.0030.0149.60
4.4.70.0050.0139.60
4.4.60.0020.0219.60
4.4.50.0010.0159.60
4.4.40.0030.0289.60
4.4.30.0000.0109.60
4.4.20.0000.0109.60
4.4.10.0000.0109.60
4.4.00.0030.0239.60
4.3.110.0000.0209.60
4.3.100.0010.0219.60
4.3.90.0030.0209.60
4.3.80.0010.0299.60
4.3.70.0020.0189.60
4.3.60.0030.0139.60
4.3.50.0000.0159.60
4.3.40.0000.0249.60
4.3.30.0030.0109.60
4.3.20.0020.0229.60
4.3.10.0030.0169.60
4.3.00.0020.0189.60

preferences:
47.8 ms | 400 KiB | 5 Q