Hi, I want to display the selling price of my product, according to the user's country. For example, USA/Canada - USD Europe - Euro UK - GBP Australia - AUD and so forth, any ideas how this can be achieved with php?
use $countries = array( 'uk' => 'GBP', 'us' => 'USD', 'com' => USD, 'au' => 'AUD'); $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); preg_match('/\.([^\.]+)$/',$hostname,$out); $tld = $out[1]; echo $countries[$tld]; PHP: That should work for the majority, although it's not an exact science. Add the tld to the countries list along with the currency type (you can extend the array to hold different info too, this was just an example)
Thanks Jay6390, but i believe I am looking for what ammoun said. I need exact location based on the visitor's IP. Is this something that is quite complex or some readymade solutions are available?
What about something like this http://www.hotscripts.com/Detailed/54660.html In fact, I think what you would be better using is http://www.hostip.info/use.html
Hi, There is a PHP module that can be installed that'll do just that, it will tell you exactly what country an IP address is located in. http://uk3.php.net/manual/en/ref.geoip.php Regards, Steve