note 69322 added to function.ereg
| From: | jaik at fluidcreativity dot co dot uk | Date: | Thu, 31 Aug 2006 15:41:40 +0000 |
| Subject: | note 69322 added to function.ereg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116545@lists.php.net to get a copy of this message | ||
Here is a fixed version of the UK postcode check function by tomas at phusis dot co dot uk. There
was a bug on line 2 of the reg expression where a closing square-bracket was doubled-up
("]]" which should've been "]").
<?php
function IsPostcode($postcode) {
$postcode = strtoupper(str_replace(chr(32),'',$postcode));
if(ereg("^(GIR0AA)|(TDCU1ZZ)|((([A-PR-UWYZ][0-9][0-9]?)|"
."(([A-PR-UWYZ][A-HK-Y][0-9][0-9]?)|"
."(([A-PR-UWYZ][0-9][A-HJKSTUW])|"
."([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))))"
."[0-9][ABD-HJLNP-UW-Z]{2})$", $postcode))
return $postcode;
else
return FALSE;
}
?>
----
Server IP: 83.138.144.80
Probable Submitter: 62.3.99.77
----
X-Spam-Status: No, hits=3.8 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
UPPERCASE_25_50 autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.ereg.php
Edit -- https://master.php.net/note/edit/69322
Del: integrated -- https://master.php.net/note/delete/69322/integrated
Del: useless -- https://master.php.net/note/delete/69322/useless
Del: bad code -- https://master.php.net/note/delete/69322/bad+code
Del: spam -- https://master.php.net/note/delete/69322/spam
Del: non-english -- https://master.php.net/note/delete/69322/non-english
Del: in docs -- https://master.php.net/note/delete/69322/in+docs
Del: other reasons-- https://master.php.net/note/delete/69322
Reject -- https://master.php.net/note/reject/69322
Search -- https://master.php.net/manage/user-notes.php