Page 1 of 1

extracting part of postcode

Posted: Thu Jul 10, 2008 10:48 am
by gurjit
ok its been a hard week, this ones easy but i just cant think properly

i have a database of postcodes

WV11 3QS
AB12 8EB
W1 7YY

I want to echo the first part of the character, so for the above examples

WV
AB
W

Re: extracting part of postcode

Posted: Thu Jul 10, 2008 12:51 pm
by jaoudestudios
You can do it various ways.

Just off the top of my head.
Explode on the white space then take the first part of the array and go through it character at a time and keep appending the result until a number is reached.

You could use a regular expression, if you wanted to be fancy.