Open mtvbrianking opened 2 years ago
function msisdn($phoneNumber, $countryCode = '256', $networkCodes = '39|76|77|78') { $phoneNumber = preg_replace('/[^\d]/', '', $phoneNumber); if(! preg_match("/^(0|{$countryCode})({$networkCodes})[\d+]{7}$/", $phoneNumber, $matches)) { throw new \InvalidArgumentException('Invalid phone number'); } if($matches[1] == '0') { $phoneNumber = substr_replace($phoneNumber, $countryCode, 0, 1); } return $phoneNumber; } echo msisdn('0788123456'); // 256788123456 - OK echo msisdn('0700123456'); // Invalid phone number echo msisdn('256788123456'); // 256788123456 - OK echo msisdn('+256788123456'); // 256788123456 - OK echo msisdn('+256 (788) 123456'); // 256788123456 - OK echo msisdn('+46 (788) 123456'); // Invalid phone number
what is the issue here ?
No apparent issue.
I just documented it as a desirable improvement for the next version borrowing from another momo plugin I worked on recently.