Valid UK Postcode Function
/**
* CALLBACK - determine if the provided postcode is valid.
*
* @param string $postcode
* @return bool TRUE if valid, FALSE otherwise
* @author George Edwards
*/
function is_valid_uk_postcode($postcode) {
$pattern = "/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/"
if (preg_match($pattern, $postcode)) {
return TRUE;
}
$this->validation->set_message('is_valid_uk_postcode', 'That is not a valid %s.');
return FALSE;
}