Results 1 to 3 of 3

Thread: My Sign Up Form Help

  1. #1
    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?

  2. #2
    Join Date
    Oct 2009
    Posts
    31
    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

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    you could do it all at once, as well
    PHP Code:
    $find = array("("")""-"" ");
    $replace "";
    $phoneNumbers str_replace($find$replace$phoneNumbers); 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •