'Why does this way of adding values to an array in php work?

I use something like

$data = [];
foreach (){
  $data[] = $api_content;
}
return $data;

the $data array does not get overwritten. Instead the values of $api_content get appended.

Is that right??? Why? I thought it gets overwritten....



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source