Validate Australian phone numbers in PHP

Here is a very basic PHP function to validate Australia phone (landline and mobile) numbers.

<?php
function validate_phone($number) {
  $number = preg_replace('/[^\d]/', '', $number);
  return preg_match('/^(0(2|3|4|7|8))?\d{8}$/', $number)
    || preg_match('/^1(3|8)00\d{6}$/', $number)
    || preg_match('/^13\d{4}$/', $number);
}
comments powered by Disqus