PHP, SQLite to JSON Array

Super simple example to get data from SQLite database and print as JSON array in PHP

<?php
header('Content-Type: application/json; charset=utf-8');

$db_name = "";   // your sqlite database

$db = new SQLite3($db_name);
$results = $db->query('SELECT * FROM `table_name`');
$json = array();

while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
   $json[] = $row;
}

echo json_encode($json);