0

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 an example of the array:
example.

This content in the array is from themoviedb API. And is opensource.

Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

0

Instead of overwrite array every time just use array_push like:

$popular[] = ['media_type' => $row["type"],$path];

Reference:

Simone Rossaini
  • 8,115
  • 1
  • 13
  • 34