#1
  1. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,974
    Rep Power
    375

    Problem with addresses from an API


    Hi,

    I have integrated my websites with an API that allows us to search for addresses. This all is working fine. The problem is the actual addresses. Sometimes they will be returned as:

    196 some Road, LONDON, AA11 1AA, or
    108 some Road, DAGENHAM, Essex, AA1 1AA or
    business name, 40 some road, London, AA11 1AA or
    building name, Church Street, Wyre Piddle, PERSHORE, Worcestershire,WR10 2JD

    Now there might be other "variation" that I have not thought of and when I did this originally I only catered for the first and third instance.

    QUESTION: how do i reliably get the address from addresses that have extra element?

    I was thinking to do something like:
    //split this by ,
    //get array_key of value with a number
    // get the next two arrays

    //if no number found then i am not sure.. i could get the first array, and the last two? which would satisfy:

    building name, Church Street, Wyre Piddle, PERSHORE, Worcestershire,WR10 2JD

    but not
    business name, 40 some road, London, AA11 1AA as i dont want the business name..
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,401
    Rep Power
    594
    Without knowing all the possible variations, one can only guess. However, I'd say splitting on commas puts you on the right track. Then if the array size is >3, throw away the first element regardless of how many there are. One problem area would be business names that contain commas.
    Last edited by gw1500se; April 30th, 2013 at 08:40 AM.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,401
    Rep Power
    594
    Another thought, most APIs, give you the option of having XML returned. That would solve your problem completely.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo