SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jun 22, 2007, 13:17 #1
- Join Date
- Dec 2003
- Location
- springfield,IL
- Posts
- 102
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Quickform - formatting a Telephone Number
I am using Quickform and one of my fields is a telephone number field. I pull this from an array field.
phone=>1234567890
In my quickform object, this is how I set it up.
PHP Code:$form->addElement('text','phone','Phone:');
Phone: 1234567890
I am able to retrieve the phone number as 10 digits, but when I display this value in Quickform, instead of seeing as 10 digits, how can I display as:
Phone: (123) 456-7890
I cant find any documentation how I can alter the format of the telephone number.
Thanks in advance for your assistance.
-
Jun 22, 2007, 13:30 #2
- Join Date
- Mar 2001
- Location
- Northwest Florida
- Posts
- 1,707
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is a function, from the PHP manual that formats phone numbers...
http://us.php.net/manual/en/function.sscanf.php#57097
If you know the phone number will always be 10 digits :
sscanf($phone, "%3s%3s%4s", $area, $prefix, $exchange);
echo "Phone : ($area) $prefix-$exchange";intragenesis, llc professional web & graphic design
-
Jun 22, 2007, 13:56 #3
- Join Date
- Dec 2003
- Location
- springfield,IL
- Posts
- 102
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
holmescreek, Ill remember this in the future for this function. But in using Quickform layout, I dont think this will help. In Quickform, it doesnt use ECHO statements.
Are you familiar with Quickform? I bought one of Sitepoints book called PHP Anthology and using the Quickform samples to build my forms. Unfortunately, it doesnt seem like to many people use this. The form example it gives is very basic.
Bookmarks