I'm trying to convert sqlite query into json. I have the following table with two columns name and age. When I print the query the format doesn't seem to be correct. why am I getting an extra key value pair?
<?php
$db = new SQLite3('info.db');
$results = $db->query('SELECT * FROM info');
while ($row = $results->fetchArray()) {
$jsonArray[] = $row;
}
echo json_encode($jsonArray)
?>
output
[{"0":"billy","name":"billy","1":"20","age":"20"}]
desired output
[{"name":"billy","age":"20"}]