Cómo escribir JSON para archivar en PHP
$data = array(
'image' => $image_url,
'mood' => $image_mood,
'date' => $image_date
);
$data_array = file_get_contents($file_path);
$data_element = json_decode($data_array, true);
$data_element[] = $data;
$new_data = json_encode($data_element, JSON_PRETTY_PRINT);
if (!file_put_contents($file_path, $new_data)) {
echo "success";
} else {
echo "fail";
}
Bi Eui