I'm trying to write to an .json file, information I collect from a database but for some reason nothing is written.
Follow the code:
require_once('../helpers/connect.php');
require_once('../models/marks.php');
$marks = Mark::select($pdo);
$rows = array();
if (isset($marks)) {
foreach ($marks as $row) {
$rows[] = array('id' => $row['id'], 'titulo' => $row['titulo'], 'descricao' => $row['decricao'], 'latitude' => $row['latitude'], 'longitude' => $row['longitude']);
}
}
$file = fopen('c:/xampp/htdocs/hemoba/assets/js/marks.json', 'w+');
fwrite($file, json_encode($rows));
fclose($file);
?>