I've got an array
$variables_a = array(
'a' => $a,
'b' => $b,
'c' => $c
);
and then another $variables_b = array('x','y','z') and I want to loop through the B array like so:
foreach($variables_b as $var) {
$variables_c[] = array($var => $$var);
}
and then merge A & C together with $variables_combined = array_merge($variables_A, $variables_C)
The output I'm hoping to get is when I print_r is
Array
(
[a] => a
[b] => b
[c] => c
[x] => x
[y] => y
[z] => z
)
but what I get is
Array
(
[a] => a
[b] => b
[c] => c
[0] => Array
(
[x] => x
)
[1] => Array
(
[y] => y
)
[2] => Array
(
[z] => z
)
)
If I change $feature_variables[] = array($feature => $$feature) to $feature_variables = array($feature => $$feature) I get
Array
(
[a] => a
[b] => b
[c] => c
[z] => z
)
i.e. the last item from $variables_b but none of the others. So where am I going wrong?