Help us understand the problem. What is going on with this article?

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

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

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

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
)
zhao-xy
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした