This is how the final output of the array should look like
$dataToReset = array (
'email_address' => $subEmail,
'status' => 'subscribed',
'interests' =>
array (
'1111111' => true,
'2222222' => true,
'3333333' => true,
'4444444' => true,
'5555555' => true,
)
);
I want to replace following part
'interests' =>
array (
'1111111' => true,
'2222222' => true,
'3333333' => true,
'4444444' => true,
'5555555' => true,
)
With a variable $interestsAdd like this
$dataToReset = array (
'email_address' => $subEmail,
'status' => 'subscribed',
$interestsAdd
);
The values that i get and what i have tried is like following, but no success!
if ($form_data['lbu_multilistsvalue'] !== ''){
$groupsSelected = $form_data['lbu_multilistsvalue'];
$selectedGroups = array_fill_keys(explode(",", $groupsSelected), true);
$interestsAdd = ['interests' => $selectedGroups];
} else {
$interestsAdd = '';
}
key=>valueinside an Array called'interests'. if this what you mean?