LoginSignup
1

More than 3 years have passed since last update.

電話番号をハイフン区切りに変換する

Last updated at Posted at 2019-10-24

ハイフン無しの電話番号をハイフン付の形式に変換する

  • ハイフン付き電話番号に分割
  • ハイフン無しの電話番号をハイフン付の形式に変換

Installation

You can install this plugin with Composer.

$ composer require rebib/phonenumbersplitter

 $provider = (new Rebib\Phonenumber\Splitter())->parse("031-234-5678");

ハイフン無し

 echo $provider->getNumberWithoutHyphen(); 
0312345678 

ハイフン付

 echo $provider->getNumberWithHyphen(); 
03-1234-5678

array

 print_r($provider->toArray());
Array
(
    [0] => 03
    [1] => 1234
    [2] => 5678
)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1