i m trying to run a code using php and json but i am getting awarning of an invalid 5121828
I’m trying to run a code using php and json but I am getting awarning of an invalid argument. Please help movies.php
$jsondata = file_get_contents(“movies.json”);
$json = json_decode($jsondata. true);
$output = “
-
”;
- Year:”.$movie[‘year’].”
- Genre:”.$movie[‘genre’].”
- Director:”.$movie[‘director’].”
foreach($json[‘movies’] as $movie){
$output.=”
”.$movie[‘title’].”
”;
$output.=”
”;
$output.=”
”;
$output.=”
”;
}
$output .=”
”;
echo $output;
?> movies.json { “movies”: [
{
“title”: “The Notebook”,
“year”: “2004”,
“genre”: “Romance”,
“director”: “Nick Cassavetes”
},
{
“title”: “Footloose”,
“year”: “1984”,
“genre”: “Drama”,
“director”: “Herbert Ross”
},
{
“title”: “The Green Mile”,
“year”: “1999”,
“genre”: “Drama”,
“director”: “Steven King”
},
{
“title”: “Friday The 13th”,
“year”: “1980”,
“genre”: “Horror”,
“director”: “Sean Cunningham”
}
] } . . .