简体   繁体   中英

Change format of phone number

I have string with phone number that I need to transform from one format to another.

Example:

"02030266079" => "0203 026 6079"

I tried:

$num = "02030266079";
$transformed= preg_replace("/^(/d{4})(/d{3})(/d{4})$/", "$1 $2 $3", $num);

But nothing happens!

$number = "12345678901";
$formatted_number = preg_replace("/^(\d{4})(\d{3})(\d{4})$/", "$1 $2 $3", $number);

It is php code and well tested, It works perfectly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM