我使用
PHP从MysqL获取一行,然后使用以下代码将其编码为JSON
原文链接:https://www.f2er.com/php/133356.html$jsonData = array(); if(MysqLi_num_rows($result) > 0){ while ($array = MysqLi_fetch_row($result)) { $jsonData[] = $array; } $json = json_encode($jsonData); echo stripslashes($json); }`
但是,我只得到行值.我想要行值和它们的列名.目前它返回以下JSON.
[["shekhar","Shekhar Chatterjee","https://graph.facebook.com/1254850974526564/picture","0"]],[["shek","","0"]]
我想有以下输出:
[{ "user":"shekhar","name":"Shekhar Chatterjee","url":"https://graph.facebook.com/1254850974526564/picture","stat":"0" },{ "user":"shekhar","stat":"0" }]