I’m trying to add a value media_type to every child of the array. The code I’m using is:
while($row = $result->fetch_assoc()) {
$url = "example";
$path = $this->get_url($url);
$popular = ['media_type' => $row["type"],$path];
}
Here’s a
example of the array.
This content in the array is from themoviedb API. And is opensource.
I can’t figure it out. Every comment helps 😀
>Solution :
Instead of overwrite array every time just use array_push like:
$popular[] = ['media_type' => $row["type"],$path];
Reference: