PHP code example of laravel-myanmar-tools / phone-number

1. Go to this page and download the library: Download laravel-myanmar-tools/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/ */

    

laravel-myanmar-tools / phone-number example snippets


use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isMyanmarPhoneNumber('09250000000'); // return true

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isMpt('09250000000'); // return true

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isOoredoo('09970000000'); // return true

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isTelenor('09790000000'); // return true

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isMec('0930000000'); // return true

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isMytel('09690000000'); // return true

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->getTelecom('09250000000'); // return "mpt"
$phoneNumber->getTelecom('09970000000'); // return "ooredoo"
$phoneNumber->getTelecom('09790000000'); // return "telenor"
$phoneNumber->getTelecom('0930000000'); // return "mec"
$phoneNumber->getTelecom('09690000000'); // return "mytel"

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->getNetworkType('09250000000'); // return "gsm"
$phoneNumber->getNetworkType('09440000000'); // return "wcdma"

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->normalize('09250000000'); // return "09250000000"
$phoneNumber->normalize('(၀၉)၂၅၀၀၀၀၀၀၀'); // return "09250000000"
$phoneNumber->normalize('၀၉-၂၅၀၀၀၀၀၀၀'); // return "09250000000"
$phoneNumber->normalize('09-၂၅ဝရဝရဝရဝ'); // return "09250000000"

$phoneNumber->normalize('09250000000', '+959'); // return "+959250000000"

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractMyanmarPhoneNumber('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်များမှာ ၀၉၂၅၀၀၀၀၀၀၀ နှင့် ၀၉၉၇၀၀၀၀၀၀၀ တို့ဖြစ်ပါသည်။'); 
// return ["09250000000", "09970000000"]

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractMpt('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 09250000000 ဖြစ်ပါသည်။'); 
// return ["09250000000"]

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractOoredoo('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 09970000000 ဖြစ်ပါသည်။'); 
// return ["09970000000"]

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractTelenor('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 09790000000 ဖြစ်ပါသည်။'); 
// return ["09790000000"]

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractMec('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 0930000000 ဖြစ်ပါသည်။'); 
// return ["0930000000"]

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractMytel('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 09690000000 ဖြစ်ပါသည်။'); 
// return ["09690000000"]

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;

$phoneNumber::macro('isAtom', function(string $phone) {
   return $this->isTelenor(phone: $phone);
});

$phoneNumber->isAtom('09790000000'); // return true