3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = ['07511 111111', '+447511 111111', '+44 (0) 7511 111111', '07211 111111' '3749853857', '0712121211233']; foreach ($test as $input) { //step 1 - reduce it to digits: preg_match_all('([\+]{0,1}[^\(\) ][0-9]+)', $input, $digits); $digits = implode($digits[0]); //now for step 2.. start by removing +44 and replacing it with 0 if (substr($digits, 0, 3) == '+44') { $digits = str_replace('+44', '0', $digits); } //by this point we should have just a UK-style number, but we must validate it: if ((substr($digits, 2, 1) > 3) && strlen($digits) == 11) { //valid UK mobile number! echo "valid UK mobile number $digits"; } }

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)
5.4.300.0100.04612.50
5.4.290.0070.04212.49
5.4.280.0070.03712.39
5.4.270.0070.03512.39
5.4.260.0050.03812.39
5.4.250.0070.04512.39
5.4.240.0070.03412.39
5.4.230.0020.04012.38
5.4.220.0060.04512.38
5.4.210.0040.03512.38
5.4.200.0070.03912.38
5.4.190.0070.03512.38
5.4.180.0040.03712.38
5.4.170.0070.03412.38
5.4.160.0050.03612.38
5.4.150.0080.03312.38
5.4.140.0070.03612.07
5.4.130.0050.03512.05
5.4.120.0060.04012.02
5.4.110.0050.03512.02
5.4.100.0060.03512.01
5.4.90.0020.04012.01
5.4.80.0030.04612.01
5.4.70.0070.03712.00
5.4.60.0050.03512.01
5.4.50.0030.03712.01
5.4.40.0050.03512.00
5.4.30.0080.03311.99
5.4.20.0080.03211.98
5.4.10.0070.03211.99
5.4.00.0060.03611.48
5.3.280.0050.03812.71
5.3.270.0050.04512.72
5.3.260.0100.04312.72
5.3.250.0100.04212.72
5.3.240.0070.04212.72
5.3.230.0060.03912.71
5.3.220.0060.03612.68
5.3.210.0070.03712.68
5.3.200.0100.03212.68
5.3.190.0040.04012.68
5.3.180.0050.03712.67
5.3.170.0060.03612.66
5.3.160.0040.03712.68
5.3.150.0040.03812.67
5.3.140.0080.03312.66
5.3.130.0090.03512.66
5.3.120.0070.03612.66
5.3.110.0080.03512.66
5.3.100.0060.03612.12
5.3.90.0070.03412.08
5.3.80.0100.04112.07
5.3.70.0060.04712.07
5.3.60.0070.04212.07
5.3.50.0070.03412.00
5.3.40.0060.03512.00
5.3.30.0040.04011.95
5.3.20.0040.03611.73
5.3.10.0090.03711.70
5.3.00.0100.03711.68

preferences:
142.21 ms | 1394 KiB | 7 Q