数据库信息分成不同的数组

here is what I'm trying to do. I'm retrieving information from a database via array. What is happening is the information from the previous array is going into the next array.

Here is the code:

$i = 0;
foreach ($array_name as $key => test_name) {
 $id = $test_name['id']

 foreach ($test_name['id] as $key => $test_id {
     $data = ModelClass::Information($test_id);
     $array_name[$i]['new_infroamtion'] = $data'
  }
}

So right now based on the code data from the table is correctly going into the first array, however, information based from the first array is going into the second array..

Let me know if you need anymore information.

Thank you

I did find a solution. What I had to do was add the following

$s = array()

Then in the for loop, I added the following code:

foreach ($test_name['id] as $key => $test_id {
   $data = ModelClass::Information($test_id);
   $s[] = $data
   $array_name[$i]['new_infroamtion'] = $s'
  }

You are using $array_name while you are iterating through $array_name. This is valid code if you want to do this, but I don't think you do. You need to change the second $array_name to something else.

$i = 0;
foreach (**$array_name** as $key => test_name) {
   $id = $test_name['id']

   foreach ($test_name['id'] as $key => $test_id {
     $data = ModelClass::Information($test_id);
     **$array_name**[$i]['new_infroamtion'] = $data
   }
}