ich have thios foreach loop to create an array. After or before it is created by the foreach, I want to add some values manually.
I tried it in this way:
$data = array();
foreach ($xyz as $single):
$data[$dynamic_name] = $single->xyz;
endforeach;
$data[oid] = '####';
but in this way, only the last added values (oid) are stored in the rray. The rest gets deleted. Where ist the error in my code?
The error is you are overwriting $dynamic_name on each pass of the loop. Also you have two arrays in the example code. I think you may want something like:
If this is not what you meant, please post more details.