I have the following data structure. I need an array of movies. Each movie has a title, rating and year.
Movies:
--Title = "The Hobbit";
--Rating = 7;
--Year = 2012;
--Title = "Lord of the rings";
--Rating = 5;
--Year = 2001;
If this was JavaScript you would have an array of objects:
const movies = [{
title:"The Hobbit",
rating:7,
year:2012
},
{
title:"Lord of the rings",
rating:5,
year:2001
}]
How do you model this in PHP? I know that you could create a class of Movie and each movie would be an instance of this class, but is this required? Can you just have non-class objects like with JavaScript?