Skip to content

Instantly share code, notes, and snippets.

@psobot
Created February 1, 2011 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save psobot/806753 to your computer and use it in GitHub Desktop.
Save psobot/806753 to your computer and use it in GitHub Desktop.
Detects the validity of an Ontario postal code.
<?php
function isOntarioPostalCode($string){
return preg_match("%[PKLNM]\d[ABCEGHJKLMNPRSTVWXYZ]( )?\d[ABCEGHJKLMNPRSTVWXYZ]\d%i"), $string);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment