If I have an array $MovieDetails = array(); and it is populated by the query below with a foreach loop (5 elements; id, movie_year, genre, image, movie_name), how do I add another element (movie_rating) to the end of the array
$AllMovies = $con ->query
("
SELECT id, movie_year, genre, image, movie_name FROM movies;
");
while($row = $AllMovies->fetch_object()) {
$MovieDetails[] = $row;
}
$MovieDetails[$row['id']] = $row;. Then if you know the movie id, you can do$MovieDetails[$id]['movie_rating'] = $rating;StdClassobject. You'll need to change tofetch_array()in order to let the posted answers work