PHP code example of alphaolomi / tz-phone-number
1. Go to this page and download the library: Download alphaolomi/tz-phone-number library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alphaolomi / tz-phone-number example snippets
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