I need to make an array of locations arrays, it must look like this
$relevanceKeys = array(
'locations' => array(
array(
'longitude' => '123456',
'latitude' => '123456'
),
array(
'longitude' => '123456',
'latitude' => '123456'
)
... more arrays
)
);
However I need to generate those on the fly, so it starts out like
$relevanceKeys = array(
'locations' => array(
)
);
And then I want to add each array from a row I found in the database:
while ($row = $result->fetch_object()) {
$array = array(
array (
'longitude' => $row->longitude,
'latitude' => $row->latitude
)
);
$relevanceKeys['locations'] = $relevanceKeys['locations'] + $array;
}
This does not work though, afterwards the file is not readable. It's exported to a different format so I can't see if it turns into the array tree correctly.
I read how to append PHP arrays from here http://php.net/manual/en/function.array-merge.php
I tried unnested $array
and nested in another array as it is now, no luck