Posted By

traeregan on 09/17/10


Tagged

php phone-number codeigniter


Versions (?)

Clean 10 Digit Phone Number


 / Published in: PHP
 

  1. private function _remove_non_numeric($string) {
  2. return preg_replace('/\D/', '', $string);
  3. }
  4.  
  5. private function _clean_phone_number($phone_number)
  6. {
  7. $CI = &get_instance();
  8.  
  9. $phone_number = $CI->_remove_non_numeric($phone_number);
  10.  
  11. if((strlen($phone_number) >= 11) AND ($phone_number[0] == '1'))
  12. {
  13. $string = substr($phone_number, 1);
  14. }
  15.  
  16. return $phone_number;
  17. }

Report this snippet  

You need to login to post a comment.