convert any phone number in us number format php

$numbers = explode("\n", '(111) 222-3333
((111) 222-3333
1112223333
111 222-3333
111-222-3333
(111)2223333
+11234567890
    1-8002353551
    123-456-7890   -Hello!
+1 - 1234567890 
');


foreach($numbers as $number)
{
    print preg_replace('~.*(\d{3})[^\d]{0,7}(\d{3})[^\d]{0,7}(\d{4}).*~', '($1) $2-$3', $number). "\n";
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
php mobile number format php format phone number with country code convert phone number any formate to php php format phone number france php format string to phone number php format us phone numbers php format us phone number convert any phone number in number format php phone number format in php formatting Phone Numbers forwch in php phone number formater php how to format phone numbers php php format uk phone number php format phone number () reformating phone number string using php format phone number php format phone number in php us country format in php php normalize phone number phone number formate php php phone ormat php show phone number in 2 decimals hide with xx php format phone number international fixer php put spaces in a phone number stored as varchar telephone number format php php encode number to United state number php phone number php cast phone number php format phone format telephone number php get prenumber from telephone in php function phone php show *********** in mobile no php php convert us phone number formatter full phone number will not display because of parameter in php full phone number will not display in php format phone enmuber in php php format phonenumber php change phone number format convert phone number php php phonenumber grouping phone number format php phone format php format phone number in php (310) 401-2802 show phone number php php format phone number with spaces php phone number format php format phone number to friendly display spacing in phone number php add phone number on php create Phone Number php php convert phone number format php standard phone number php format phone number telephone number masking php how get divar phone numbers php how to format a phonenumber php PHP FORMAT PHONE NUMBER FUNCTION phone number php format number to phone number php format number to phone number php convert any phone number in us number format php
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source