1. Go to this page and download the library: Download piyo2/format-phone-jp 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/ */
piyo2 / format-phone-jp example snippets
use piyo2\format\PhoneJP;
$f = new PhoneJP();
// Valid number
$f->validate('0120444444'); // => true
$f->format('0120444444'); // => '0120-444-444'
$f->formatIfValid('0120444444'); // => '0120-444-444'
// Invalid number
$f->validate('0127-12-3456'); // => false
$f->format('0127-12-3456'); // => '0127-12-3456' (= input value)
$f->formatIfValid('0127-12-3456'); // => null