Current location: Hot Scripts Forums » Programming Languages » PHP » PHP format phone numbers

PHP format phone numbers

Reply
  #1 (permalink)  
Old
Newbie Coder
 
Join Date: Sep 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
PHP format phone numbers

My listings shows 8881112222 I want to change this to this
888.111.2222 Some address are correct. There are many to change by hand.
is there a way to check and change this format?

Thanks,
Larry
__________________
Free Auctions Listing
http://www.auctionsincolorado.com

Listing you Business/Clubs/Software
http://www.greatplaces4u.com
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
Nico's Avatar
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,129
Thanks: 12
Thanked 93 Times in 89 Posts
Give this a try.

PHP Code:

function format_tel_num($number)
{
    return 
preg_replace('/\d{3}/''$0.'str_replace('.'nulltrim($number)), 2);

Usage example.
PHP Code:

$number '8881112222';

echo 
format_tel_num($number); // Output: 888.111.2222


$number '888.111.2222';

echo 
format_tel_num($number); // Output: 888.111.2222 
Reply With Quote
  #3 (permalink)  
Old
Newbie Coder
 
Join Date: Sep 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks

That works perfect !! Thanks again !!
__________________
Free Auctions Listing
http://www.auctionsincolorado.com

Listing you Business/Clubs/Software
http://www.greatplaces4u.com
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
floating numbers, php, mysql, filemaker pro chippewapublishing PHP 12 12-19-06 03:50 PM
I need Help validating Australian Phone numbers imparator JavaScript 2 07-25-06 07:20 AM
PHP and Cell Phone Browsers cyberfolli PHP 2 12-12-05 10:13 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM


All times are GMT -5. The time now is 06:30 PM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.