Last active
December 18, 2015 19:19
-
-
Save alancoleman/5831765 to your computer and use it in GitHub Desktop.
Isolate just the area identifier from a UK postcode. So 'BA6 5TY' would result in 'BA' and 'N5 7TY' would result in 'N'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define postcode | |
$postcode = "BA6 5TY"; | |
// Isolate first two characters of the postcode and replace any integer with nothing | |
$postcode_area = preg_replace("/[0-9]/","",substr($postcode, 0, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment