A little help here.. Your code is a little wrong...
A quick primer...
$data = array('one' => '1', 'two' => '2');
If you do a variable dump should look something like this...
$data {
one = 1
two = 2
}
$data[] = array('one' => '1', 'two' => '2');
$data[] = array('three' => '3', 'four' => '4');
If you do a variable dump should look something like this...
$data {
array() {
one = 1
two = 2
}
array(){
three = 3
four = 4
}
}
if we took this one step further and did this:
$data = array('one' => '1', 'two' => '2');
$data = array('three' => '3', 'four' => '4');
The second $data replaces the first and you get a variable dump that looks like this:
$data {
three = 3
four = 4
}
Note the difference..
In this most recent variation of your code every time you go to the foreach loop you will step through each element of the $datas variable that has been loaded and you will send a large array of all of your key/value pairs to the setvars.
The fix SHOULD be simple... Just remove the $[] from the $datas[] line.
I had thought to suggest the $datas[] suggestion until I realized how the code was running.
By adding the [] you are creating a 3 dimension array...
Without it you are doing a 2 dimension array.
I BELIEVE then you will step through each key/value pair and send this to setvars and SHOULD work. Assuming that setVars can accept an array.
In brief I think it is getting made more complicated than it needs to be. The original post should have worked just by moving the foreach loop within the for loop.
But again, this type of bug can be figured out by doing a series of variable dumps at different stages and looking at the value. This is a coding issue and not a database issue.
I do not have time to run this code at this time but I should be reasonably accurate.
Rodney