关于再次警告php中的foreach()无效警告

时间:2015-05-28 01:31:33

标签: php foreach

为什么我收到此PHP警告?

foreach()

提供的参数无效

我不知道,如果我的PHP有问题或不兼容,我一直在更改并更新我的PHP版本。

这个代码:

<?php               
    // Generate a latitude/longitude pair using Google Maps API
    list($lat,$lng) = $foursquare->GeoLocate($location);                
    // Prepare parameters
    $params = array("ll"=>"$lat,$lng");     
    // Perform a request to a public resource
    $response = $foursquare->GetPublic("venues/search",$params);
    $venues = json_decode($response);
?>    
        <?php foreach($venues->response->venues as $venue): ?>
            <div class="venue">
                <?php                           
                    if(isset($venue->categories['0']))
                    {
                        echo '<image class="icon" src="'.$venue->categories['0']->icon->prefix.'88.png"/>';
                    }
                    else
                        echo '<image class="icon" src="https://foursquare.com/img/categories/building/default_88.png"/>';
                        echo '<a href="https://foursquare.com/v/'.$venue->id.'" target="_blank"/><b>';
                        echo $venue->name;
                        echo "</b></a><br/>";

                    if(isset($venue->categories['0']))
                    {
                        if(property_exists($venue->categories['0'],"name"))
                        {
                            echo ' <i> '.$venue->categories['0']->name.'</i><br/>';
                        }
                    }

                    if(property_exists($venue->hereNow,"count"))
                    {
                            echo ''.$venue->hereNow->count ." people currently here <br/> ";
                    }

                    echo '<b><i>History</i></b> :'.$venue->stats->usersCount." visitors , ".$venue->stats->checkinsCount." visits ";                        
                ?>              
            </div>              
        <?php endforeach; ?>

1 个答案:

答案 0 :(得分:0)

我不知道json数据。但尝试这个选项。如果我有json可能是我无法帮助你更多细节。

var $ = require('jquery');
var http                    = require("http")
, fs                        = require("fs")
, qs                        = require("querystring")
, port                  = 5555


var server = http.createServer(function(request, response) {

$.getJSON( 'http://query.yahooapis.com/v1/public/yql?q=select * from    yahoo.finance.historicaldata where symbol = 'AAL'&format=jsonstore://datatables.org/alltableswithkeys
    ', cbFunc);

});

function cbFunc(data){
console.log(data);
}

server.listen(port);

console.log('Server is listening to http://localhost/ on port ' + port + '...');