nguyenanhung / vn-telco-phonenumber
PhoneNumber VN Telco
Installs: 8 561
Dependents: 3
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 3
Open Issues: 0
Requires
- php: >=7.0
- giggsey/libphonenumber-for-php: ^8.13
- nguyenanhung/my-debug: >=3.0
Requires (Dev)
- kint-php/kint: >=3.0
- dev-master
- v3.x-dev
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.x-dev
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.0
- v1.1.10
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5.10
- v1.1.5.9
- v1.1.5.8
- v1.1.5.7
- v1.1.5.6
- v1.1.5.5
- v1.1.5.4
- v1.1.5.3
- v1.1.5.2
- v1.1.5.1
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
This package is auto-updated.
Last update: 2024-12-21 20:36:18 UTC
README
Library detect carrier Vietnam telco: Viettel, VinaPhone, MobiFone, Vietnamobile ...
Format Phone number
Library use libphonenumber
by Google, version PHP by giggsey
Version
- All version
v1.x
,v2.x
support PHP>=5.6
- All version
v3.x
support PHP>=7.0
Installation
Manual install
Step 1: Save library to your project
cd /your/to/path
wget https://github.com/nguyenanhung/vn-telco-phonenumber/archive/master.zip
unzip master.zip
Step 2: Init to Project
<?php require '/your/to/path/Phone_number.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number();
Install with composer
Step 1: Install package
composer require nguyenanhung/vn-telco-phonenumber
Step 2: Init to Project
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number();
How to Use
Get Version of Library
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number(); echo $phone->getVersion(); // Print: 1.0.9
Valid Phone Number
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number(); $my_number = '0163 295 3760'; $my_number_2 = '0163 295 376'; echo $phone->is_valid($my_number, 'VN'); // Print: true echo $phone->is_valid($my_number_2, 'VN'); // Print: false
Get National Number
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number(); $my_number = '0163 295 3760'; echo $phone->get_national_number($my_number); // Print: 1632953760
Check is Possible Number
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number(); $my_number = '0163 295 3760'; $my_number_2 = 'abc'; echo $phone->is_possible_number($my_number, 'VN'); // Print: true echo $phone->is_possible_number($my_number_2, 'VN'); // Print: false
Format Phone number
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number(); $my_number = '0163 295 3760'; echo $phone->format($my_number); // Print: 841632953760 echo $phone->format($my_number, 'vn'); // Print: 01632953760 echo $phone->format($my_number, 'vn_human'); // Print: 0163 295 3760 echo $phone->format($my_number, 'hidden'); // Print: 0163***3760
Detect Carrier from Phone number
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number(); $my_number = '0163 295 3760'; echo $phone->detect_carrier($my_number); // Print: Viettel Mobile echo $phone->detect_carrier($my_number, 'id'); // Print: 2 echo $phone->detect_carrier($my_number, 'name'); // Print: Viettel echo $phone->detect_carrier($my_number, 'short_name'); // Print: viettel
Conver Old Number to New Number (or New Number to Old Number)
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number(); $my_number = '0163 295 3760'; echo $phone->vn_convert_phone_number($my_number, 'old'); // Print: 841632953760 echo $phone->vn_convert_phone_number($my_number, 'new'); // Print: 84332953760 echo $phone->vn_convert_phone_number($my_number, 'old', 'vn'); // Print: 01632953760 echo $phone->vn_convert_phone_number($my_number, 'new', 'vn'); // Print: 0332953760
Return Array Old number and New number
<?php require '/your/to/path/vendor/autoload.php'; use \nguyenanhung\VnTelcoPhoneNumber\Phone_number; $phone = new Phone_number(); $my_number = '0163 295 3760'; echo $phone->vn_phone_number_old_and_new($my_number); // Print: ["841632953760", "84332953760"] echo $phone->vn_phone_number_old_and_new($my_number, 'vn'); // Print: ["01632953760", "0332953760"] ... // other format is the same $phone->format() method: VN, VN_HUMAN, E164, INTERNATIONAL, NATIONAL, RFC3966, HIDDEN, HIDDEN_HEAD, HIDDEN_MIDDLE, HIDDEN_END
Contact
If any question & request, please contact following infomation
From Hanoi with Love <3