This is very interesting post, to find location i used API of hostip.info website. first i need to find IP address of client. based on ip address i gonna fetch location.
For IP address of client please view find the ip address post.
here, i m using PHP Simple HTML DOM Parser to read content from webpage.
Simple HTML DOM Parser
A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way!
Require PHP 5+.
Supports invalid HTML.
Find tags on an HTML page with selectors just like jQuery.
Extract contents from HTML in a single line.
to download Parser go to http://simplehtmldom.sourceforge.net/ site.
and include that file on top of php file.
$html = file_get_html('http://api.hostip.info/?ip='.$ip);
foreach($html->find('gml:name') as $element)
$result = @split("",$element);
$fresult = @split("",$result);
This code return the exact city name.!!
hope you like it.!