a classic wrapper for libphonenumber for PHP by https://github.com/giggsey
composer require jenesiszw/phone_lib:dev-master
<?php
use JenesisZw\PhoneLibrary;
require __DIR__ . '/vendor/autoload.php'';
$number = "0782000340";
$data = $phone = (new PhoneLibrary($number, 'ZW'))
->parse()
->getIsValid()
->getNationalFormat()
->getInternationalFormat()
->getCarrierProvider()
->getPhoneDescription()
->getTimeZone()
->done();
function dd($data)
{
echo "<code>";
echo "<pre>";
die(print_r($data, true));
echo "</pre>";
echo "</code>";
}
dd($data);
Array
(
[isValid] => true
[nationalFormat] => 0782000340
[internationalFormat] => +263 78 200 0340
[carrierProvider] => Econet
[country] => Zimbabwe
[timeZone] => Africa/Harare
)
- getIsValid()
- check if number is valid or not
- returns bool
- getInternationalFormat()
- get international format from the parsed number
- getNationalFormat()
- get national format from the parsed number
- getE164Format()
- get E164 format from the parsed number
- getCarrierProvider()
- get carrier provider from the parsed number
- getTimeZone()
- get time zone from the parsed number
- getPhoneDescription()
- get country name from the parsed number
-
parse()
-
done()
- returns details for the parsed phone number
Note: parse() and done() are the required methods, others are optional