PHP code example of nguyenanhung / vn-telco-phonenumber
1. Go to this page and download the library: Download nguyenanhung/vn-telco-phonenumber 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/ */
nguyenanhung / vn-telco-phonenumber example snippets
guyenanhung\VnTelcoPhoneNumber\Phone_number;
$phone = new Phone_number();
guyenanhung\VnTelcoPhoneNumber\Phone_number;
$phone = new Phone_number();
nguyenanhung\VnTelcoPhoneNumber\Phone_number;
$phone = new Phone_number();
echo $phone->getVersion(); // Print: 1.0.9
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
nguyenanhung\VnTelcoPhoneNumber\Phone_number;
$phone = new Phone_number();
$my_number = '0163 295 3760';
echo $phone->get_national_number($my_number); // Print: 1632953760
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
guyenanhung\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
guyenanhung\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
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
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