Link to home
Start Free TrialLog in
Avatar of ellandrd
ellandrdFlag for Ireland

asked on

UK Postcode

I have a list of UK Postcode that I need to check for the correct format.  

Users address are entered like: $address = "street, town, city, county, postcode";

I split these up into parts like so: $part = explode(',',$Address); which gives me:

$part[0] = 'street';
$part[1] = 'town';
$part[2] = 'city';
$part[3] = 'county';
$part[4] = 'postcode';

But some users enter their phone number instead of the postcode which gives me a pain in the head...

So i'd like to check the last part in the string so I can either put the value in a $telephone = '0123456789'; or $part[4] = 'AB10 1LB';

So how would i check the format of a Postcode? example: AB10 1LB

thank you
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial