I want to remove the double quote in my json_encode, i.e. my code:
<?php require_once 'config.inc.php'; connect(); $result = mysql_query("SELECT * from ranking WHERE posicion BETWEEN ".$params['pos_ini']." AND ".$params['pos_fi']) or die('Could not query'); if(mysql_num_rows($result)){ $array_json=array(); $filas = mysql_num_rows($result); $columnas = mysql_num_fields($result); for($i=0;$i<$filas;$i++) { $fila_dato = mysql_fetch_assoc($result); for($k=0;$k<$columnas;$k++) { $campo = mysql_field_name($result,$k); $campo = str_replace('\"', '', $campo); $array_json[$i][$campo] = $fila_dato[$campo]; } } $array_final = json_encode($array_json); $array_final = preg_replace('/"([a-zA-Z]+[a-zA-Z0-9]*)":/','$1:',$array_final); echo $array_final; } else { echo '[]'; } ?>
My result:
[{"id_posiciones":"1",posicion:"1",nick:"biwer",puntos:"1000",uid:"1",pais:"ES",idioma:"ES","device_version":"4"}]
I want to remove the double quote "id_posiciones" and "device_version".
How can I do for the result:
[{id_posiciones:"1",posicion:"1",nick:"biwer",puntos:"1000",uid:"1",pais:"ES",idioma:"ES",device_version:"4"}]
source share