Top Questions

  • 5.11 Years

    • Category : Php
    • Location : Chandigarh, India
    • Posted On : Dec 7, 2015

    1 Answers

    View More

    admin

    admin

    5.3 Years

    Answered:

    Dec 19, 2018

    jghjghjghj

    <?php
    class ZiptoAddress()
    {
    function getLnt($zip)
    {
    $url = "http://maps.googleapis.com/maps/api/geocode/json?address=".$zip."&sensor=false";
    $result_string = file_get_contents($url);
    $result = json_decode($result_string, true);
    //$result1[]=$result['results'][0];
    //$result2[]=$result1[0]['geometry'];
    //$result3[]=$result2[0]['location'];
    //return $result[0];
    //return $result['results'][0]['geometry']['location'];
    return $result['results'][0];
    //print_r($result1[0]['formatted_address']);
    }
    }
    $val = getLnt('90001');
    echo "Address: ".$val['formatted_address']."<br>";
    echo "Latitude: ".$val['geometry']['location']['lat']."<br>";
    echo "Longitude: ".$val['geometry']['location']['lng']."<br>";
    ?>

     

Add Your Answer

When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.