
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.68 KB | hits: 9 | expires: Never
function sanitizeSender($phone, $countryCode) {
// Added by Diego Massanti to sanitize the phone number in all possible ways, depending on carrier and country code.
// This function standarizes the phone numbers so we have a single format systemwide.
// $countryCode is a string with only numbers.
// First, remove all spaces
trim($phone);
$phone = str_replace(" ", "", $phone);
// Second we remove the country code and any strange sign (if received)
if (substr($phone, 0, 2) == $countryCode) {
$phone = substr($phone, 2, strlen($phone));
} else if (substr($phone, 0, 3) == "+".$countryCode) {
$phone = substr($phone, 3, strlen($phone));
}
return $phone;
}