how remove the backslash (“\”) in the json response using php?

前端 未结 5 718
伪装坚强ぢ
伪装坚强ぢ 2020-12-30 12:07

I try to add a row of mysql query into JSON whit php. I use this code:

public function lugaresCercanos($lng, $lat, $distance){
$result=mysql_query(\"SELECT n         


        
5条回答
  •  孤城傲影
    2020-12-30 12:53

    Thanks, I resolve it.

    $info=array();
        while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
            array_push($info,$row);
        }
        $info;
    $result_final->lugares_cercanos = $info;
    

    Print this:

    {"logstatus":"1","lugares_cercanos":[{"nombre":"Rio Amazonas","distancia":"5119.000"}{"nombre":"Swissotel Quito","distancia":"5823.000"}{"nombre":"Laguna de Yaguarcocha","distancia":"71797.000"}]}
    

提交回复
热议问题