I have a list of postcodes in the UK and their co-ordinates... I've also written a nice function that measures the distance between two postcodes.
When my user logs in their postcode will be stored in a cookie, when they do a search for events I want to show them the events closest to them which in my head tells me I'd have to do the following.
-Collect ALL events and store them in an array
-Start a foreach loop
-Take the postcode of the event & from the cookie and parse them into a calculate function.
-Calculate function calculates the distance from the user and stores it in a new array
-Once all events have had their distance calculated they are sorted in ascending order by the "distancefrom" field and the top 10 are displayed to the user.
My questions are... what happens when there are 1000's of events?? Surley having that many events put into an array will take long and be really inefficient. Memory problems aswell?
Is my thinking right? Is this the best way to do what I want to do?
Many thanks :)