I have a foreach loop and need to dynamically create the key value pairs and build the array.
After running the foreach loop, it should produce something like
I need to know how to use foreach loop and build the sample array like above
PHP
Last Comment
debbieau1
8/22/2022 - Mon
Chris Stanyon
Not sure what you mean - you need something to loop through with the foreach loop (such as an array)
What exactly do you want to run the foreach loop on?
debbieau1
ASKER
Hi Chris
I have values coming from a database table and I need to save these into another table.
I have a foreach loop which iterates through. I want to merge these so it looks like the sample below. I had problems with each (key value pair replacing, rather than combining them into one array
foreach($test as $k=>$sampleEntry)
{
the key value pair was in here
}
The goal is to combine the ones from the loop into one array like below.
What exactly do you want to run the foreach loop on?