Simple UK Phone Number Validation
This is a simple solution which should help a lot with accidental errors, but it’s still very easy for someone to enter a fake number if they want to. The first line of code removes anything thats not a number from a submitted post variable called ‘phone’. The second line checks the number begins with a 0, followed by 1-9 (’00′ is not allowed as it’s the UK dialling prefix for international calls), followed by 8 or 9 other digits. The example below works with PHP 5.2.0 & above.
$phone = ereg_replace('[^0-9]', '', $_POST['phone']);
if (!filter_var($phone, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => "/^0[1-9][0-9]{8,9}$/")))) {
echo 'Please enter your phone number correctly';
}

