I have and associated array looking like this:
array(225) {
[0]=>
array(3) {
["id"]=>
string(1) "1"
["firstname"]=>
string(2) "me"
["lastname"]=>
string(2) "ab"
[1]=>
array(3) {
["id"]=>
string(1) "2"
["firstname"]=>
string(3) "you"
["lastname"]=>
string(2) "bc"
As you may the structure of all elements is identical. What I want to do is to create dynamiclly new key in the nested arrays, something like this :
array(225) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["firstname"]=>
string(2) "me"
["lastname"]=>
string(2) "ab"
["newKey"]=>
string() "1,2,3,....n"
[1]=>
array(3) {
["id"]=>
string(1) "2"
["firstname"]=>
string(3) "you"
["lastname"]=>
string(2) "bc"
["newKey"]=>
string() "1,2,3,....x"
and I want to add new records to the value with key ["newKey"] but in a way that the old value is not deleted but as shown above - we separate every new value with comma from the others.
I tried array_push and some other things but can't get the exact result I want.