Go Back   Dynamic Drive Forums > General Coding > PHP
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-04-2009, 01:12 PM
impload impload is offline
New Comer (less than 5 posts)
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Cool My Sign Up Form Help

Hi I have a sign up form and it is linked to various php scripts that send api calls.

The api we use marks this as correct:
Phone number: 8676544544

But this just brings an error:
Phone number: 545-645-4242
Phone number: (545) 445-2454
even if there are spaces in between.

Because of the dashes in between the numbers. How can I have the php script remove the dashes(-) in the phone number or even the spaces if there are any inputed?
Reply With Quote
  #2  
Old 11-04-2009, 09:02 PM
newbtophp newbtophp is offline
Junior Coders
 
Join Date: Oct 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default

PHP Code:
<?php
/*replace the $phonenumber variable with a global variable you use in your script*/

//remove dashes
$phonenumber str_replace("-"""$phonenumber);
//remove spaces
$phonenumber str_replace(" """$phonenumber);
//remove brackets
$phonenumber str_replace("("""$phonenumber);
//remove brackets
$phonenumber str_replace(")"""$phonenumber);

?>
545-645-4242

would to turn into:

5456454242
Reply With Quote
  #3  
Old 11-05-2009, 03:36 AM
traq's Avatar
traq traq is online now
Senior Coders
 
Join Date: Apr 2008
Location: So.Cal
Posts: 464
Thanks: 22
Thanked 45 Times in 45 Posts
Default

you could do it all at once, as well
PHP Code:
$find = array("("")""-"" ");
$replace "";
$phoneNumbers str_replace($find$replace$phoneNumbers); 
__________________
i design your custom anything
$question = (2B) || (!2B);
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:45 AM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.