Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Help with OR in IF statement ( code included )

  1. #11
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    For the purposes of readability and reusability. PHP may try to make these coding staples as awkward as possible, but at least we've still got the good old function available to us.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #12
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    Heres a tested function to check all US zipcodes:

    PHP Code:
    <?php
    function validate_zip($zipcode){
        return 
    preg_match('/^[0-9]{5}([- ]?[0-9]{4})?$/'$zipcode);
    }
    ?>

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
  •