Skip to content

Instantly share code, notes, and snippets.

View matthewhaworth's full-sized avatar

Matthew Haworth matthewhaworth

  • MH Web Development Ltd
  • Manchester, UK
View GitHub Profile
@MarkBaker
MarkBaker / UK Postcode Parse
Last active August 29, 2015 14:06
UK Postcode Parsing
function parsePostcode2($postcode) {
$postcode = preg_replace('/\s*/','',strtoupper($postcode));
$sector = substr($postcode,0,-2);
$outcode = $district = substr($sector,0,-1);
list($area) = sscanf($district,'%[A-Z]');
$incode = substr($postcode,-3);
return array(