Syntax:
file_put_contents(file_name.json.json_object);
$jsonData = {"poster":"film_poster.jpg","title":"fname","cost":"279.00","actors":[{"name":"Actor First Name","age":35,"city":"CityName"}]}
eg:
file_put_contents("geeks_data.json", $jsonData);
$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";
}