p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > PHP/MySQL > Pro PHP
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 2nd, 2009, 01:02 PM
Registered User
Points: 56, Level: 1
Points: 56, Level: 1 Points: 56, Level: 1 Points: 56, Level: 1
Activity: 35%
Activity: 35% Activity: 35% Activity: 35%
 
Join Date: Oct 2009
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formatting phone number

Hello,

I am trying to format US phone numbers to look like this (###) ###-#### and the code that I used is:
Code:
function format_phone($phone_1)
{
	$phone = preg_replace("/[^0-9]/", "", $phone_1);

	if(strlen($phone_1) == 7)
		return preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $phone_1);
	elseif(strlen($phone_1) == 10)
		return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1) $2-$3", $phone_1);
	else
		return $phone_1;
}
This was inputted into the VirtuemartOrdersReport.php file and it does not seem to work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation For Phone Number and Mobile Number dhruthi.ram99 Javascript How-To 9 January 10th, 2008 02:14 AM
GridView - Phone column formatting jnks2005 ASP.NET 2.0 Basics 1 February 14th, 2007 06:36 PM
Phone # field formatting! Nostromo77 ASP.NET 2.0 Basics 3 December 19th, 2006 02:02 PM
formatting phone numbers xslt_student XSLT 0 August 7th, 2006 05:10 PM
phone number validation debjanib ASP.NET 1.0 and 1.1 Professional 0 June 6th, 2006 01:01 PM



All times are GMT -4. The time now is 08:00 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc