techker Posted May 31, 2008 Share Posted May 31, 2008 hey guys i need to do a web site that hase a kilometer calculator? like the guy puts montreal to toronto it egals 1200 kilometers.. does this exist already?if not is it doable?...lol Quote Link to comment https://forums.phpfreaks.com/topic/108119-kilometer-calculator/ Share on other sites More sharing options...
AndyB Posted May 31, 2008 Share Posted May 31, 2008 ... like the guy puts montreal to toronto it egals 1200 kilometers.. If that kind of 'accuracy' is good enough, just use a random number calculator. 'As the crow flies' it's around 500 km. Unless you want to host an enormous database - and then you would only get the point-to-point distance not how far you actually travel - you could use a third-party service to provide the information. http://www.google.com/search?q=distance+between+cities offers lots Quote Link to comment https://forums.phpfreaks.com/topic/108119-kilometer-calculator/#findComment-554211 Share on other sites More sharing options...
448191 Posted May 31, 2008 Share Posted May 31, 2008 Supposedly, this should do the trick. It isn't my code (I suck at math) and I haven't tested it, but give it a try. $lat1 = 46.2341938036161; $lon1 = -63.124778021257015; $lat2 = 46.4141938036161; $lon2 = -63.118571124705284; $distance = (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180); Of course you still need a database with coordinates. Quote Link to comment https://forums.phpfreaks.com/topic/108119-kilometer-calculator/#findComment-554215 Share on other sites More sharing options...
techker Posted May 31, 2008 Author Share Posted May 31, 2008 wow..ok you lost me what do i do with that. but anyways i think im going to use google.thx Quote Link to comment https://forums.phpfreaks.com/topic/108119-kilometer-calculator/#findComment-554246 Share on other sites More sharing options...
448191 Posted May 31, 2008 Share Posted May 31, 2008 It's a script that takes longitude and latitude of two locations and calculates the distance in KM. But you're right, if you don't know what to do with it, better use Google instead Quote Link to comment https://forums.phpfreaks.com/topic/108119-kilometer-calculator/#findComment-554249 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.