I need to make an array of locations arrays, it must look like this
$relevanceKeys = array(
\'locations\' => array(
array(
\'longitud
Just append the array like this:
$relevanceKeys['locations'][] = $array;
//^^ See here
You don't have to merge them all the time!
Also I think you want to change this:
$array = array(
array (
'longitude' => $row->longitude,
'latitude' => $row->latitude
)
);
to this to get your expected structure:
$array = array(
'longitude' => $row->longitude,
'latitude' => $row->latitude
);
For more information about array see the manual: http://php.net/manual/en/language.types.array.php