3v4l.org

run code in 300+ PHP versions simultaneously
<html> <head><title>Simple PHP Script to get the Latitude and Longitute using Google API - Blog.Theonlytutorials.com</title></head> <body> <h2>Simple PHP Script to get the Latitude and Longitude using Google API - Blog.Theonlytutorials.com</h2> <br /> <form action="" method="post"> Type Your Location : <input type="text" name="myaddress" /> (eg. Whitefield, Bangalore) </form> <br /> <?php //blog.theonlytutorials.com //author: agurchand if(isset($_POST['myaddress'])){ $myaddress = urlencode($_POST['myaddress']); //here is the google api url $url = "http://maps.googleapis.com/maps/api/geocode/json?address=$myaddress&sensor=false"; //get the content from the api using file_get_contents $getmap = file_get_contents($url); //the result is in json format. To decode it use json_decode $googlemap = json_decode($getmap); //get the latitute, longitude from the json result by doing a for loop foreach($googlemap->results as $res){ $address = $res->geometry; $latlng = $address->location; $formattedaddress = $res->formatted_address; ?> <br /> <!-- Print the Latitude and Longitude --> <?php echo "Latitude: ". $latlng->lat ."<br />". "Longitude:". $latlng->lng; ?> <h2>Dynamic Location on Google Map!</h2> <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=<?php echo $myaddress;?>&amp;ie=UTF8&amp;hq=&amp;hnear=<?php echo urlencode($formattedaddress);?>&amp;t=m&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe> <?php } } ?> </body> </html>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<html> <head><title>Simple PHP Script to get the Latitude and Longitute using Google API - Blog.Theonlytutorials.com</title></head> <body> <h2>Simple PHP Script to get the Latitude and Longitude using Google API - Blog.Theonlytutorials.com</h2> <br /> <form action="" method="post"> Type Your Location : <input type="text" name="myaddress" /> (eg. Whitefield, Bangalore) </form> <br /> </body> </html>

preferences:
265.75 ms | 406 KiB | 393 Q