Skip to content

How to mask phone number in PHP?

$data = '+11234567890';

if(  preg_match( '/^\+\d(\d{3})(\d{3})(\d{4})$/', $data,  $matches ) )
    $result = $matches[1] . '-' .$matches[2] . '-' . $matches[3];
    return $result;
See also  Python code snippet - How to rinstalll re?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.