dozpv84422 2017-05-02 15:10
浏览 56
已采纳

PHP数组没有使用json_encode转换为JSON [duplicate]

This question already has an answer here:

I am trying to convert my $response array to JSON but it is not converting. I tried to echo the values in the array to be sure that it is not null.

    if($row['count(*)']>0)
    {
        $sql="select * from guide_city_detail where CITY='$place'";
        $result = $conn->query($sql);
        $row = $result1->fetch_assoc();
        $row = array_map('utf8_encode', $row);
        $response['status']=1;
        $response['city']=$row['CITY'];
        $response['state']=$row['STATE'];
        $response['country']=$row['COUNTRY'];
        $response['heads']=$row['HEADS'];
        $response['col1']=$row['COL1'];
        $response['col2']=$row['COL2'];
        $response['col3']=$row['COL3'];
        $response['col4']=$row['COL4'];
        $response['col5']=$row['COL5'];
        $response['col6']=$row['COL6'];
        $response['col7']=$row['COL7'];
        $response['col8']=$row['COL8'];
        $response['col9']=$row['COL9'];
        //echo $response['country'];
    }
    else
    {
        $response['status']=0;// save the entry for future references
        $output = shell_exec("java -cp \".;D:/letsgo/mysql.jar;D:/letsgo/jsoup.jar;\" GeneralPopulate $place 2>&1");
        //echo "$output";
    }
    $res=json_encode($response);
    echo $res;
}
</div>
  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 C++银行卡系统 HELP
      • ¥15 JS如何把上面这种数据类型转换成下面这种的
      • ¥15 ubuntu 16.04.2 oss上传文件并显示耗时
      • ¥15 存储过程调用没有进行逻辑计算
      • ¥20 Kali破解WIFI密码中出现这个问题是什么意思
      • ¥15 R语言数据分析的相关问题
      • ¥15 模型导入SP后贴图纹理只有一个,拆了四张UV的,怎么解决?
      • ¥15 检索带order by 非常慢
      • ¥20 python 爬虫 token 加密方式
      • ¥20 IAR环境报错reading CPU status failed