Php json#U解码可以';t显示阵列

Php json#U解码可以';t显示阵列,php,arrays,json,Php,Arrays,Json,好的,我已经看了几个例子,我似乎无法显示数组或元素。它一直返回为空-。我有以下JSON(来自mapquest) 我尝试将其添加到这样的数组中 $array =json_decode($data, true); 然而,无论我如何尝试打印或检查内容,它都返回为空,我实际上只是尝试打印出lat lng和adminArea5。 任何帮助都会很好 这是完整的代码 <?php $where = filter_input(INPUT_GET, 'where', FILTER_SANITIZE_STRI

好的,我已经看了几个例子,我似乎无法显示数组或元素。它一直返回为空-。我有以下JSON(来自mapquest)

我尝试将其添加到这样的数组中

$array =json_decode($data, true);
然而,无论我如何尝试打印或检查内容,它都返回为空,我实际上只是尝试打印出lat lng和adminArea5。 任何帮助都会很好

这是完整的代码

<?php
$where = filter_input(INPUT_GET, 'where', FILTER_SANITIZE_STRING);
$source = "getLat";
if ($source =="getLat")
{
    ob_start();
    $getsource = array('location' =>$where,
            'type'=>$getWhat,
            'callback'=>'ResultSet'
    );
    $url = "http://www.mapquestapi.com/geocoding/v1/address?key=123456789" . http_build_query($getsource, '', "&");
//print_r($url);
    $data_mapquest = file_get_contents($url);
    $array = json_decode($data_mapquest, true);
    ob_end_flush();
}
?>


不要包含使响应成为响应的
'callback'=>'ResultSet'
参数。

看起来不像JSON…那不是JSON。这是一个Javascript表达式。除了函数调用包装外,键是不带引号的。这就是为什么简单的json解码在这里不起作用的原因。好的-任何建议-我在这里有点新手,但任何指导都会很好。请在你的代码中添加适当的选项卡。好的-我想我可以删掉renderGeocodeThanks-我知道它必须很简单--
<?php
$where = filter_input(INPUT_GET, 'where', FILTER_SANITIZE_STRING);
$source = "getLat";
if ($source =="getLat")
{
    ob_start();
    $getsource = array('location' =>$where,
            'type'=>$getWhat,
            'callback'=>'ResultSet'
    );
    $url = "http://www.mapquestapi.com/geocoding/v1/address?key=123456789" . http_build_query($getsource, '', "&");
//print_r($url);
    $data_mapquest = file_get_contents($url);
    $array = json_decode($data_mapquest, true);
    ob_end_flush();
}
?>