A PHP package to validate and format Tanzanian phone numbers. It uses the Tanzania Communications Regulatory Authority Schema to reconcile and validate the phone number and get the network operator.
You can install the package via composer:
composer require alphaolomi/tz-phone-number
use Alphaolomi\TzPhoneNumber\PhoneNumber;
$phoneNumber = new PhoneNumber('255 754 123 456');
// To get the country code
$phoneNumber->getCountryCode(); // 255
// To get the Network Operator
$phoneNumber->getNetworkOperator(); // Vodacom
// To check if the phone number is valid
$phoneNumber->isValid(); // true
// To get the phone number in international format
$phoneNumber->getNumber(); // +255754123456
// To get the phone number in local format
$phoneNumber->getLocalNumber(); // -754123456
- The phone number must be in the format
255 754 123 456
or754 123 456
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.