joshtronic / php-googleplaces

PHP Wrapper for the Google Places API
MIT License
85 stars 38 forks source link

Sample foreach to loop through results? #16

Closed contempoinc closed 7 years ago

contempoinc commented 7 years ago

First awesome work! Do you have a quick example of a foreach to loop through the results?

contempoinc commented 7 years ago

Got everything working, just having an issue spitting out the results within a foreach probably overthinking it for example. Any help is much appreciated!

if(!empty($results)) {

            echo '<ul class="marB20 places-nearby">';
        $i = 0;
            foreach($results as $result){           
            echo '<li>';
                            echo $result[$i]->name;
                            echo $result[$i]->rating;
            echo '</li>';
            $i++;
                }
            echo '</ul>';

}

contempoinc commented 7 years ago

Got it figured out, here's the completed function/foreach example for anyone else out there:

https://gist.github.com/contempoinc/f360871a7be751db190ab40617b2ed73