-1
我想通過PHP訪問sqlite3數據庫,並將輸出獲取到json。在數據庫行中讀取時重複輸出
<?php
$db = new sqlite3('my.db') or die("Could not open database");
$sql = "SELECT * FROM teams";
$result = $db->query($sql);
while($row = $result->fetcharray())
{
$output[]=$row;
}
$json = '{"team":'.json_encode($output).'}';
json_decode($json);
echo $json;
$db->close();
?>
JSON輸出:
{"0":16,
"team_id":16,
"1":"VfB Stuttgart",
"team_name":"VfB Stuttgart",
"2":"bl1",
"league_shortcut":"bl1"}
他把0,1,2的輸出,爲什麼呢?