PHP code example of damien-louis / libphonenumber-shortcuts

1. Go to this page and download the library: Download damien-louis/libphonenumber-shortcuts 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/ */

    

damien-louis / libphonenumber-shortcuts example snippets


//06 05 04 03 02
$result = \PhoneNumberShortcuts::format('+33605040302', PhoneNumberShortcuts::NATIONAL);

//+33 6 05 04 03 02
$result = \PhoneNumberShortcuts::format('0605040302', PhoneNumberShortcuts::INTERNATIONAL, 'FR');

//true
$isValid = \PhoneNumberShortcuts::isValid('+33 607080910');

//true
$isValid = \PhoneNumberShortcuts::isValid('+33 607080910', 'FR');

//false
$isValid = \PhoneNumberShortcuts::isValid('+1607080910', 'FR');

//GB
$result = \PhoneNumberShortcuts::getRegionCodeForNumber('+44 117 496 0123');

//FR
$result = \PhoneNumberShortcuts::getRegionCodeForNumber('+33 1 02 03 04 05');

//US
$result = \PhoneNumberShortcuts::getRegionCodeForNumber('+12135096995');

//null
$result = \PhoneNumberShortcuts::getRegionCodeForNumber('notanumber');