PHP搜索数据库输出的JSON出现重复
PHP使用sql搜索出来的数据,转换成json后就出现重复。
例如下面的0和hps_userid是一样的,1和hps_userid2一样的。
怎么去掉重复的?或直接让sql搜出后,列名为key,值为value?
语句:
$result = mysql_query("select * from hpsubject");
$json = json_encode(mysql_fetch_array($result));
echo $json;
结果:
{"0":"1","hps_userid":"1","1":"1","hps_userid2":"1","2":"154436","hps_time":"154436"}
音无结弦D
9 years, 8 months ago