PDA

View Full Version : right trim variable


cocoonfx
04-25-2009, 09:12 PM
hello

Is it possible to right trim a variable in a mysql database using PHP

i.e

I have a field in the mysql table called 'loc'.

i.e Castle grounds, B78 8ED

I want to only grab the postcode i.e

B78 8ED

davidj
04-26-2009, 09:58 AM
explode the contents of the field using a comma

you will create an array from the result

example

if your field was 'address' and the contents looks like this

47, grange st, my town, newcastle, ne2 8rg

If you returned that into a var


$addy = $row['address'];

$addyArray = explode(',',$addy);


you can now grab any value in the array

cocoonfx
04-26-2009, 09:36 PM
cheers dj i will give that a go.