Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.68 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function sanitizeSender($phone, $countryCode) {
  2.         // Added by Diego Massanti to sanitize the phone number in all possible ways, depending on carrier and country code.
  3.         // This function standarizes the phone numbers so we have a single format systemwide.
  4.         // $countryCode is a string with only numbers.
  5.        
  6.        
  7.         // First, remove all spaces
  8.         trim($phone);  
  9.         $phone = str_replace(" ", "", $phone);
  10.  
  11.         // Second we remove the country code and any strange sign (if received)
  12.         if (substr($phone, 0, 2) == $countryCode) {
  13.                 $phone = substr($phone, 2, strlen($phone));
  14.         } else if (substr($phone, 0, 3) == "+".$countryCode) {
  15.                 $phone = substr($phone, 3, strlen($phone));    
  16.         }
  17.        
  18.         return $phone;
  19. }