Return to Snippet

Revision: 61636
at December 30, 2012 10:46 by chrisvogt


Initial Code
function is_phone($phone) {
    $phone = preg_replace('/[^\d]+/', '', $phone);
    $num_digits = strlen($phone);
    if($num_digits == 10 || $num_digits == 11) {
        return $phone;
    } else {
        return FALSE;
    }
}

Initial URL

                                

Initial Description
Return a pure 10-digit phone number if the number given is 10 digits or 11 digits.

Initial Title
Check 10- and 11- digit phone numbers

Initial Tags
phone, number

Initial Language
PHP