Create associative array from Foreach Loop PHP
Associative array in foreach statement:
foreach($nodeids as $field => $value) {
$field_data[$field]=$value;
}
Output:
Array(
$field => $value,
$field => $value
...
);
insertion in CodeIgniter:
$res=$this->db->insert($bundle_table,$field_data);
You need to change your $aMemberships assignment
$aMemberships[] = $aMemb['Name'];
If you want an array
$aMemberships[$aMemb['ID']] = $aMemb['Name'];
if you want a map.
What you are doing is appending an array to an array.