PHP code example of faso-dev / phone-number-checker

1. Go to this page and download the library: Download faso-dev/phone-number-checker 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/ */

    

faso-dev / phone-number-checker example snippets


/*
 * Copyright (c) 2021. | All Rights Reserved
 * @Author <FASO-DEV> [email protected]
 */


use FSDV\BF\Utils\Extractor\PhoneNumberExtractor;
use FSDV\BF\Utils\Extractor\PhoneNumberPrefixExtractor;
use FSDV\BF\Validator\PhoneNumber;

date('51000000'); //output: true

//Vérifie l'opérateur mobile d'un numéro au format Burkinabé
//=======MOOV========
PhoneNumber::isMoov('+22651000000'); //output: true
PhoneNumber::isMoov('0022651000000'); //output: true
PhoneNumber::isMoov('0022654000000'); //output: false
//=======ORANGE========
PhoneNumber::isOrange('+22656000000'); //output: true
PhoneNumber::isOrange('0022656000000'); //output: true
PhoneNumber::isOrange('0022678000000'); //output: false
//=======TELECEL========
PhoneNumber::isTelecel('+22658000000'); //output: true
PhoneNumber::isTelecel('0022679000000'); //output: true
PhoneNumber::isTelecel('0022677000000'); //output: false

//Obtenir l'opérateur mobile d'un numéro de télephone
PhoneNumber::getOperator('+22651000000'); //output: MOOV BURKINA
PhoneNumber::getOperator('+22656000000'); //output: ORANGE BURKINA
PhoneNumber::getOperator('+22658000000'); //output: TELECEL BURKINA

//Obtenir les préfixes d'un opérateur mobile
PhoneNumber::getPhonePrefixes(PhoneNumber::MOOV_BURKINA); //output: ['01','02','51','52','53','60','61','62','63','70','71','72','73]
PhoneNumber::getPhonePrefixes(PhoneNumber::ORANGE_BURKINA); //output: ['06',07','54','55','56','57','64','65','66','67','74','75','76','77']
PhoneNumber::getPhonePrefixes(PhoneNumber::TELECEL_BURKINA); //output: ['58','59','68','69','78','79]

//Extraire le prefixe d'un numéro au format Burkinabé
PhoneNumberPrefixExtractor::extract('+22651000000'); //output: 51
PhoneNumberPrefixExtractor::extract('+22674000000'); //output: 74
PhoneNumberPrefixExtractor::extract('+22668000000'); //output: 68

//Extraire le numéro sans l'indicatif du pays
PhoneNumberExtractor::extract('+22651000000'); //output: 51000000
PhoneNumberExtractor::extract('+22674000000'); //output: 74000000
PhoneNumberExtractor::extract('+22668000000'); //output: 68000000