3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($number){ if( !preg_match('/^[0-9][0-9\- ]+[0-9]$/', $number) || // (strlen($number) > 12) || // (strlen($number) < 7) || (preg_match_all('/[0-9]/', $number, $foo) > 12 ) || (preg_match_all('/[0-9]/', $number, $foo) < 7 ) || (preg_match('/[ \-]{2,}/', $number)) ){ throw new Exception('Invalid phone number'); } return trim(preg_replace('/[^0-9]/','',$number)); } echo ReformatPhoneNumber('012-345 69') ."\n"; foreach(array('012345', '-012345 678', '01203- 34566', '123456678875432','1234x567','1234567890123') as $invalid){ try { ReformatPhoneNumber($invalid); }catch(Exception $e){ continue; } echo "ACCEPTED $invalid !!!!!!!!\n"; }

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.0160.00316.62
8.3.50.0130.00917.48
8.3.40.0110.00419.17
8.3.30.0060.00918.93
8.3.20.0050.00319.02
8.3.10.0080.00020.85
8.3.00.0040.00419.75
8.2.180.0150.00016.88
8.2.170.0070.00722.96
8.2.160.0030.01020.33
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0060.00319.73
8.2.110.0070.00320.98
8.2.100.0130.00018.03
8.2.90.0050.00319.20
8.2.80.0000.00817.97
8.2.70.0040.00417.88
8.2.60.0080.00017.93
8.2.50.0030.00518.10
8.2.40.0080.00022.18
8.2.30.0000.00818.30
8.2.20.0020.00517.90
8.2.10.0040.00417.98
8.2.00.0030.00517.98
8.1.280.0040.01125.92
8.1.270.0080.00024.66
8.1.260.0050.00326.35
8.1.250.0030.00628.09
8.1.240.0060.00322.81
8.1.230.0060.00617.89
8.1.220.0050.00317.74
8.1.210.0080.00018.77
8.1.200.0070.00317.48
8.1.190.0090.00017.48
8.1.180.0030.00618.10
8.1.170.0030.00718.62
8.1.160.0000.00822.20
8.1.150.0030.00618.78
8.1.140.0040.00417.69
8.1.130.0030.00317.86
8.1.120.0040.00417.64
8.1.110.0000.00717.59
8.1.100.0000.00817.48
8.1.90.0070.00017.63
8.1.80.0000.00817.69
8.1.70.0070.00017.61
8.1.60.0040.00417.75
8.1.50.0000.00817.53
8.1.40.0040.00417.72
8.1.30.0000.00817.74
8.1.20.0040.00417.83
8.1.10.0040.00417.80
8.1.00.0040.00417.69
8.0.300.0000.00918.77
8.0.290.0040.00417.13
8.0.280.0000.00718.40
8.0.270.0000.00717.30
8.0.260.0000.00617.09
8.0.250.0040.00417.16
8.0.240.0000.00817.18
8.0.230.0000.00717.11
8.0.220.0000.00717.07
8.0.210.0040.00417.02
8.0.200.0030.00317.16
8.0.190.0030.00617.18
8.0.180.0000.00817.13
8.0.170.0030.00617.17
8.0.160.0040.00417.19
8.0.150.0050.00317.02
8.0.140.0000.00917.05
8.0.130.0030.00313.62
8.0.120.0040.00417.20
8.0.110.0000.00717.21
8.0.100.0040.00417.16
8.0.90.0040.00417.16
8.0.80.0160.00017.10
8.0.70.0040.00417.03
8.0.60.0000.00717.22
8.0.50.0000.00817.07
8.0.30.0070.01717.47
8.0.20.0110.00717.35
8.0.10.0070.00017.32
8.0.00.0110.01016.87
7.4.330.0050.00013.32
7.4.320.0060.00016.74
7.4.300.0030.00316.91
7.4.290.0030.00316.82
7.4.280.0000.00716.79
7.4.270.0040.00416.91
7.4.260.0050.00013.56
7.4.250.0000.00916.69
7.4.240.0000.00716.92
7.4.230.0000.00716.55
7.4.220.0110.00716.85
7.4.210.0100.00916.91
7.4.200.0000.00716.99
7.4.190.0080.00016.88
7.4.160.0130.00316.72
7.4.150.0200.00016.87
7.4.140.0110.00716.80
7.4.130.0070.01316.77
7.4.120.0070.01016.92
7.4.110.0060.01216.99
7.4.100.0140.00416.85
7.4.90.0030.01516.73
7.4.80.0140.00316.59
7.4.70.0120.00916.84
7.4.60.0040.01416.75
7.4.50.0060.00316.70
7.4.40.0040.01416.77
7.4.30.0140.00416.69
7.4.00.0070.01115.23
7.3.330.0070.00013.41
7.3.320.0000.00613.51
7.3.310.0000.00716.54
7.3.300.0000.00816.50
7.3.290.0090.00916.56
7.3.280.0090.00916.56
7.3.270.0090.00916.79
7.3.260.0090.00816.77
7.3.250.0080.01016.73
7.3.240.0090.00616.54
7.3.230.0060.01216.52
7.3.210.0100.00716.62
7.3.200.0040.01319.39
7.3.190.0110.01116.57
7.3.180.0100.00716.63
7.3.170.0180.00616.73
7.3.160.0080.00816.50
7.3.120.0100.00815.12
7.3.110.0100.00615.09
7.3.100.0080.00815.18
7.3.90.0100.00515.17
7.3.80.0050.00614.93
7.3.70.0060.00815.02
7.3.60.0030.00715.01
7.3.50.0060.00714.96
7.3.40.0120.00315.01
7.3.30.0020.00815.08
7.3.20.0050.01016.78
7.3.10.0020.01016.69
7.3.00.0060.00716.84
7.2.330.0100.00716.71
7.2.320.0090.00916.67
7.2.310.0140.00816.88
7.2.300.0080.00816.85
7.2.290.0070.01016.90
7.2.250.0020.01715.26
7.2.240.0120.00815.21
7.2.230.0000.01315.20
7.2.220.0090.00515.26
7.2.210.0020.01315.18
7.2.200.0060.00915.34
7.2.190.0020.00915.09
7.2.180.0100.00515.36
7.2.170.0070.00915.33
7.2.160.0100.00715.21
7.2.150.0090.00617.24
7.2.140.0000.01417.21
7.2.130.0050.00717.03
7.2.120.0020.01217.20
7.2.110.0030.00817.12
7.2.100.0060.00617.15
7.2.90.0080.00617.14
7.2.80.0110.00516.92
7.2.70.0060.01016.96
7.2.60.0080.00917.01
7.2.50.0110.00317.10
7.2.40.0070.00717.08
7.2.30.0100.00617.06
7.2.20.0050.00517.11
7.2.10.0070.00917.03
7.2.00.0070.01017.90
7.1.330.0080.00616.03
7.1.320.0060.00915.89
7.1.310.0060.00715.98
7.1.300.0040.00915.72
7.1.290.0050.01016.00
7.1.280.0020.00915.97
7.1.270.0030.01215.91
7.1.260.0070.01016.01
7.1.250.0040.00815.80
7.1.240.0090.00315.77
7.1.230.0040.00816.04
7.1.220.0100.00315.98
7.1.210.0030.01215.88
7.1.200.0060.00615.86
7.1.190.0060.00915.75
7.1.180.0000.01015.96
7.1.170.0070.00716.03
7.1.160.0000.01015.89
7.1.150.0060.00916.07
7.1.140.0070.00416.00
7.1.130.0080.00415.91
7.1.120.0000.01615.69
7.1.110.0150.00315.89
7.1.100.0050.00817.10
7.1.90.0060.00915.73
7.1.80.0060.00315.66
7.1.70.0030.00716.63
7.1.60.0110.00917.67
7.1.50.0070.01216.57
7.1.40.0100.00616.03
7.1.30.0110.00415.95
7.1.20.0050.00515.97
7.1.10.0030.01015.87
7.1.00.0030.03319.03
7.0.330.0000.01115.46
7.0.320.0090.00315.66
7.0.310.0030.00615.26
7.0.300.0080.00015.27
7.0.290.0050.00515.65
7.0.280.0080.00415.68
7.0.270.0030.00715.32
7.0.260.0030.00615.41
7.0.250.0120.00315.46
7.0.240.0060.00615.69
7.0.230.0080.00815.52
7.0.220.0030.00615.68
7.0.210.0060.01015.45
7.0.200.0100.00515.22
7.0.190.0040.01115.59
7.0.180.0060.00915.74
7.0.170.0040.01115.45
7.0.160.0100.00315.55
7.0.150.0060.01215.46
7.0.140.0090.03618.82
7.0.130.0030.00615.61
7.0.120.0050.03518.85
7.0.110.0030.00915.61
7.0.100.0150.00015.45
7.0.90.0110.00415.50
7.0.80.0100.00315.62
7.0.70.0030.00915.66
7.0.60.0050.04117.77
7.0.50.0050.03216.64
7.0.40.0110.04016.72
7.0.30.0080.03016.87
7.0.20.0180.03217.00
7.0.10.0170.04216.89
7.0.00.0070.03216.88
5.6.400.0090.00614.27
5.6.390.0030.01014.25
5.6.380.0000.01114.39
5.6.370.0000.01614.18
5.6.360.0030.01014.27
5.6.350.0030.00714.52
5.6.340.0000.01414.69
5.6.330.0060.00314.34
5.6.320.0000.00814.61
5.6.310.0080.00514.60
5.6.300.0000.01814.53
5.6.290.0130.00314.27
5.6.280.0000.04317.69
5.6.270.0070.00414.59
5.6.260.0100.00314.43
5.6.250.0030.01314.46
5.6.240.0080.00414.30
5.6.230.0070.00414.37
5.6.220.0030.01014.39
5.6.210.0050.04817.42
5.6.200.0060.03216.38
5.6.190.0050.04217.28
5.6.180.0220.04017.37
5.6.170.0160.03117.38
5.6.160.0080.04317.41
5.6.150.0060.03216.53
5.6.140.0040.04916.32
5.6.130.0070.03016.33
5.6.120.0070.03917.75
5.6.110.0100.03217.80
5.6.100.0130.03817.88
5.6.90.0050.04517.64
5.6.80.0030.03317.31
5.6.70.1570.02117.44
5.6.60.0030.01014.28
5.6.50.0070.00713.95
5.6.40.0030.00914.21
5.6.30.0000.01414.32
5.6.20.0100.00714.25
5.6.10.0000.01614.47
5.6.00.0080.00614.17
5.5.380.0040.01214.35
5.5.370.0000.01214.30
5.5.360.0060.00314.30
5.5.350.0170.04317.24
5.5.340.0070.04116.23
5.5.330.0070.02217.25
5.5.320.0150.02817.38
5.5.310.0160.02817.29
5.5.300.0020.03616.21
5.5.290.0050.04416.15
5.5.280.0080.04217.63
5.5.270.0000.04217.79
5.5.260.0140.03317.67
5.5.250.0130.04517.34
5.5.240.0070.03017.18
5.5.230.0070.00714.05
5.5.220.0060.00614.06
5.5.210.0050.00414.52
5.5.200.0070.00714.46
5.5.190.0100.00314.09
5.5.180.0060.01214.27
5.5.170.0030.01314.26
5.5.160.0130.00014.46
5.5.150.0090.00614.20
5.5.140.0040.01114.18
5.5.130.0000.01414.48
5.5.120.0030.01014.20
5.5.110.0030.00614.34
5.5.100.0070.01014.36
5.5.90.0000.01414.23
5.5.80.0070.01014.45
5.5.70.0090.00914.09
5.5.60.0100.00714.07
5.5.50.0040.01214.48
5.5.40.0070.00714.39
5.5.30.0040.01214.39
5.5.20.0090.00614.13
5.5.10.0030.00714.00
5.5.00.0000.01114.25
5.4.450.0020.04115.65
5.4.440.0000.02815.70
5.4.430.0080.03415.75
5.4.420.0100.03915.71
5.4.410.0100.02615.73
5.4.400.0100.03715.63
5.4.390.0030.04415.49
5.4.380.0060.04015.48
5.4.370.0050.02315.64
5.4.360.0080.02815.61
5.4.350.0050.04115.67
5.4.340.0100.04015.55
5.4.330.0030.01312.11
5.4.320.0050.04315.63
5.4.310.0070.02515.55
5.4.300.0080.04515.61
5.4.290.0100.03815.63
5.4.280.0060.04315.47
5.4.270.0030.03215.67
5.4.260.0100.02115.59
5.4.250.0030.03515.49
5.4.240.0080.04015.47
5.4.230.0080.04015.55
5.4.220.0050.02815.67
5.4.210.0060.02315.51
5.4.200.0070.03515.63
5.4.190.0070.04315.62
5.4.180.0020.04515.47
5.4.170.0020.02315.54
5.4.160.0000.02515.62
5.4.150.0060.02815.66
5.4.140.0040.03414.24
5.4.130.0030.04214.22
5.4.120.0030.03114.23
5.4.110.0030.02514.23
5.4.100.0030.04314.30
5.4.90.0040.02514.24
5.4.80.0050.03014.26
5.4.70.0080.02814.26
5.4.60.0050.02714.28
5.4.50.0060.02414.18
5.4.40.0070.02514.28
5.4.30.0070.03014.25
5.4.20.0070.03314.19
5.4.10.0030.03514.18
5.4.00.0050.02314.03
5.3.290.0030.04113.35
5.3.280.0060.03313.37
5.3.270.0020.02713.32
5.3.260.0050.03313.38
5.3.250.0020.02513.36
5.3.240.0070.02013.38
5.3.230.0080.03713.35
5.3.220.0020.04013.35
5.3.210.0090.01813.34
5.3.200.0070.03213.30
5.3.190.0070.04013.35
5.3.180.0020.04413.33
5.3.170.0010.03813.35
5.3.160.0040.03913.34
5.3.150.0090.02113.28
5.3.140.0050.03713.34
5.3.130.0080.04013.33
5.3.120.0030.04413.36
5.3.110.0090.03313.34
5.3.100.0080.02013.08
5.3.90.0020.03713.09
5.3.80.0080.03613.01
5.3.70.0030.03613.04
5.3.60.0060.03913.06
5.3.50.0050.04313.03
5.3.40.0150.03213.04
5.3.30.0040.04213.01
5.3.20.0030.02612.90
5.3.10.0050.03312.90
5.3.00.0060.03512.86
5.2.170.0000.03711.12
5.2.160.0000.03311.16
5.2.150.0030.05311.12
5.2.140.0070.06711.19
5.2.130.0030.03011.11
5.2.120.0030.06711.00
5.2.110.0070.05311.05
5.2.100.0070.04711.08
5.2.90.0070.06011.11
5.2.80.0130.05711.13
5.2.70.0130.05711.02
5.2.60.0030.03711.22
5.2.50.0070.04010.96
5.2.40.0030.06310.99
5.2.30.0000.04311.04
5.2.20.0000.04710.92
5.2.10.0030.05310.94
5.2.00.0030.06310.75
5.1.60.0030.0539.97
5.1.50.0070.05310.00
5.1.40.0070.0479.96
5.1.30.0070.05310.36
5.1.20.0100.03310.28
5.1.10.0070.03310.04
5.1.00.0000.03010.05
5.0.50.0000.0408.52
5.0.40.0000.0438.49
5.0.30.0030.0378.23
5.0.20.0000.0408.23
5.0.10.0030.0308.23
5.0.00.0000.0478.23
4.4.90.0070.0308.23
4.4.80.0000.0278.23
4.4.70.0000.0408.23
4.4.60.0000.0278.23
4.4.50.0000.0378.23
4.4.40.0030.0538.23
4.4.30.0000.0308.23
4.4.20.0030.0338.23
4.4.10.0030.0308.23
4.4.00.0070.0408.23
4.3.110.0000.0378.23
4.3.100.0000.0338.23
4.3.90.0030.0338.23
4.3.80.0070.0508.23
4.3.70.0030.0378.23
4.3.60.0030.0338.23
4.3.50.0070.0308.23
4.3.40.0030.0378.23
4.3.30.0000.0408.23
4.3.20.0000.0208.23
4.3.10.0030.0238.23
4.3.00.0030.0378.23

preferences:
51.47 ms | 401 KiB | 5 Q