首先,請看看這個JSON http://ws.luyencong.net/data/search/query.php?do=json只返回一個對象JSON而不是多個對象PHP?
下面是它的代碼:
/* --- Execute query and get the data. --- */
$query = $db->query("SELECT t.* FROM ".TABLE_PREFIX."threads t");
while($data = $db->fetch_array($query))
{
$results[] = array($data['subject'] => $data['subject']);
$json = json_encode($results, JSON_FORCE_OBJECT);
}
/* --- Print the results to the screen, for future purposes. --- */
echo $json;
但我想輸出JSON格式將是這樣的:http://ws.luyencong.net/data/search/json.txt
幫助將不勝感激。感謝任何事情。
祝您有美好的一天!
所以你希望我們告訴你用[]包裝你的JSON? :) –
請包括一個簡單的例子:現在如何看待輸出,應該怎麼看。鏈接的輸出是不可讀的。 – matino
你想要一個json散列,其中有像'B \ u1ed1 c \ u00e1o th \ u00e0nh l \ u1eadp di \ ueec5n \ u0111 \ u00e0n Luy \ c7n C \ u00f4ng'? – miah