I am trying to validate a zip code from a form using the following code.
if (!is_int($zipcode) || $zipcode == ""){ $error[] = "Zip Code"; //error array }
I don't know why this won't work?
Whats the problem? If it just doesn't do as it should then try wrapping the expressions in braskets like this:
if ((!is_int($zipcode)) || ($zipcode == "")){ $error[] = "Zip Code"; //error array }
That may work. Try it.
Nick
Three reasons: 1) Datatypes: $zip1 = "19107"; $zip2 = 19107; is_int($zip1) <> is_int($zip2) 2) Zip+4 US zipcodes aren't integers(example: "19104-2307") 3) International zipcodes/postal codes aren't integers. Example: 322 Regents Park Road Finchley London N3 2QQ <-- postal code United Kingdom
-- Michael Darkstreak Computing & Innovations www.darkstreak.com
Doh!
🙂