I have a requirement to add an element to a PHP array. I would like to know whether I have to iterate over all the elements and add it OR do I have a shortcut to get this done?
[
"A": ["id": 12, "name": "test1"],
"B": ["id": 13, "name": "test2"]
]
I have to add "cut_id": 1 to each array and it should become:
[
"A": ["id": 12, "name": "test1", "cut_id": 1],
"B": ["id": 13, "name": "test2", "cut_id": 1]
]
foreach()andarray_push()should do the trick.