hi all,
I am trying to make an array that looks like this:
Array
(
[status] =>
[MERGE0] => removed@email.address
[merge_fields] => Array
(
[MERGE1] => James
[MERGE2] => doe
)
)
In my code, there is an undefined number of [merge_fields], so I am using the code below to try create an array in the above format:
$i = 0;
foreach($data as $d):
$mergeField[] = ['MERGE'.$i.'' => $d];
$i++;
endforeach;
$json2 = [
'status' => $status,
'MERGE0' => $data['email'],
'merge_fields' => $mergeField
];
However, this outputs this:
Array
(
[status] =>
[MERGE0] => removed@email.address
[merge_fields] => Array
(
[0] => Array
(
[MERGE0] => removed@email.address
)
[1] => Array
(
[MERGE1] => James
)
[2] => Array
(
[MERGE2] => doe
)
[3] => Array
(
[MERGE3] => Masterton
)
)
)
Basically, I need to get rid of the parent keys for each merge item... How do I go about this??