Skip to content

Instantly share code, notes, and snippets.

@xvoland
Last active August 29, 2015 14:16
Show Gist options
  • Save xvoland/3d255a37c5d3498ae286 to your computer and use it in GitHub Desktop.
Save xvoland/3d255a37c5d3498ae286 to your computer and use it in GitHub Desktop.
<?php
if (isset($_POST['postcode'])) {
$regions = array(
'm' => 'manchester',
'n' => 'london',
's' => 'london',
'b' => 'birmingham',
'br' => 'kent',
'ct' => 'kent',
'da' => 'kent',
'me' => 'kent',
'tn' => 'kent',
'cr' => 'surrey',
'gu' => 'surrey',
'kt' => 'surrey',
'rh' => 'surrey',
'sm' => 'surrey',
'tn' => 'surrey',
'tw' => 'surrey'
);
$postCode = strtolower($_POST['postcode']);
if (array_key_exists($postCode, $regions)) {
$res = $regions[$postCode];
} else if(array_key_exists(substr($postCode, 1, 1), $regions)) {
$res = $regions[substr($postCode, 1, 1)];
} else {
$res = null;
}
if (!is_null($res)) {
header('Location: /sell-house/' . $res . '.html');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment