function tel_dialstring ($str) { $str = tel_convert_vanity($str); // International w/ Plus and Prefix if (preg_match('/^\+[\d]{1,3}\s[\(\)\d\.a-z]+/i', $str)) { return $str; } // US Domestic 10-Digit elseif (preg_match('/^[\(]?[2-9]{1}[\d]{2}[\-\)\.\s]?[\da-z]{3}[\-\.\s]?[\da-z]{4}$/i', $str)) { return '+1 '.preg_replace('/[^\da-z\+]/i', '', $str); } else { return preg_replace("/[^0-9]/", "", $str); } }
function us10digit ($str) { $str = tel_convert_vanity($str); $str = preg_replace('/[^\d]/','', $str); if (is_tel(substr($str,-10))) { return substr($str,-10); } else { $this->form_validation->set_message('us10digit', 'The %s field must contain a 10-digit US fax number.'); return false; } }