Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8194339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:47:23+00:00 2026-06-07T04:47:23+00:00

Here is a simple code I’m trying to run but it does not out

  • 0

Here is a simple code I’m trying to run but it does not out put any data. Could someone help? Thanks!!

<?php

$addr = "Hotels in ottawa canada";
$a = urlencode($addr);
$geocodeURL = 
"https://maps.googleapis.com/maps/api/geocode/json?address=$a&sensor=false&key=my key";

$ch = curl_multi_init($geocodeURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_multi_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$geocode = json_decode($result);

$lat = $geocode->results[$i]->geometry->location->lat;
$lng = $geocode->results[$i]->geometry->location->lng; 
echo $formatted_address = $geocode->results[$i]->formatted_address;
echo $geo_status = $geocode->status;
echo $location_type = $geocode->results[0]->geometry->location_type;
echo $location_type = $geocode->results[$i]->geometry->premise;
echo $street_address = $geocode->results[$i]->street_address;


?>

Social Classifieds

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:47:25+00:00Added an answer on June 7, 2026 at 4:47 am

    If your looking to pass multiple addresses in parallel to the google api and then parse the results as one, ive put together a little example that does just that and fixed your curl multi code. Hope it helps.

    <?php 
    $urls = array(
    'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true',
    'http://maps.googleapis.com/maps/api/geocode/json?address='.urlencode('Hotels').'&sensor=true');
    
    $response = curl_get_multi($urls);
    
    //Handle response array
    foreach($response as $json){
        $result = json_decode($json);
        //echo $result->status.' ';
    
        //Iterate each result
        foreach($result->results as $res){
            //lat
            echo $res->geometry->location->lat.' ';
            //lng
            echo $res->geometry->location->lng.' ';
            //formatted_address
            echo $res->formatted_address.' ';
            //location_type
            echo $res->geometry->location_type.' ';
            echo '<br/>';
        }
        echo '<hr />';
    }
    
    /**
     * Curl multi function
     *
     * @param Array $urls
     * @return Array
     */
    function curl_get_multi($urls) {
        $curly = array();
        $result = array();
    
        $mh = curl_multi_init();
        foreach ($urls as $id=>$url) {
            $curly[$id] = curl_init();
            curl_setopt($curly[$id], CURLOPT_URL,            $url);
            curl_setopt($curly[$id], CURLOPT_HEADER,         0);
            curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curly[$id], CURLOPT_TIMEOUT,        2);
            curl_setopt($curly[$id], CURLOPT_USERAGENT,      'CurlRequest');
            curl_setopt($curly[$id], CURLOPT_REFERER,        $url);
            curl_setopt($curly[$id], CURLOPT_AUTOREFERER,    true);
            curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, true);
    
            curl_multi_add_handle($mh, $curly[$id]);
        }
        $running = null;
        do {
            curl_multi_exec($mh, $running);
        } while($running > 0);
        foreach($curly as $id => $c) {
            $result[$id] = curl_multi_getcontent($c);
            curl_multi_remove_handle($mh, $c);
        }
        curl_multi_close($mh);
        return $result;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a simple code snippet and I cannot figure out why does it
I'm using simple jcarousel here is ther code: http://jsfiddle.net/w6fLA/ I'm trying to show div
Really simple question here but bugging me for long enough to ask. Code looks
Here is a simple code in C++: cout << Press Any Key To Exit...;
Here is a simple code to animate webview screen. But the problem is, the
Here is my simple code, which works fine if called from php or any
here my simple code to add filename and their associated icon to virtualtreeview PFileInfoRec
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
Here is a simple code that shows what I think is a bug when
Here is the super simple code i have: HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.OptionWriteEmptyNodes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.