(note: new to json language) I have this bit of code that's supposed to get data from a json file and display it in a table with a set of data on the topic of movies on each row, but the code isn't working and comes up with error "Unidentified index: produced_by on line 20" or directed_by on line 21, and so on for all 7 different data names.
<?php
$jdata = file_get_contents("cats-in-movies.json");
//decode the retrieved json file into an array
$contents = json_decode($jdata, true);
//how long is the array
$i = count($contents);
echo
//create the table
"<table style border=3px solid black; ><tr><th>Producer</th><th>Director</th><th>Title</th><th>Year made</th><th>URL</th><th>Image</th><th>Poster URL</th></tr>";
//from 0 to length_of_array show the values in the table
for ($x = 0; $x < $i; $x++) {
echo
"<tr>
<td>" . $contents[$x]["produced_by"] . "</td>
<td>" . $contents[$x]["directed_by"] . "</td>
<td>" . $contents[$x]["title"] . "</td>
<td>" . $contents[$x]["year"] . "</td>
<td>" . $contents[$x]["url"] . "</td>
<td>" . $contents[$x]["image"] . "</td>
<td>" . $contents[$x]["url_poster"] . "</td>
</tr>";
}
?>
Its really basic code used from elsewhere that worked with a variable of $jdata being actual json written inside the file instead of file_get_contents, but now with a file it doesn't seem to work, and Im trying to let the json file be updated so more data can be added in somewhat easily so just copying the text into the php file won't work for me.
The actual JSON file is here: https://pastebin.com/TavfuziF
Ive tried for several hours now and I can't find anything anywhere on how to fix this so any help would be greatly appreciated.