I'm trying to send a nested PHP array to Javascript. But Javascript parses the top level as an object.
The Teams array should contain 2 other arrays with each 2 team names
As you can see in the screenshot and the json, the "Teams" is an object.
"teams":{"1":["test","test"],"2":["test","test"]},"results":[]}
This is the code I'm using to build up the nested array
$iterator = 0;
for($i = 0; $i < $competition->teams->count(); $i++) {
if($i % 2 == 0) {
$iterator++;
}
$data["teams"][$iterator][] = "test";
}
The funny thing is, it is working when the array is not multidimensional. For example the following example doesn't return Teams as an object.
I'm guessing if I remove the array keys it might work, but It's impossible to have a nested array without array keys, right?
Any idea what I might be doing wrong? And how I can get Javascript to just see my nested array without seeing it as an object.
Thank you!