I would like to extend an assoc array. The original array is like
$arr = [[
'ID' => 0,
'TEXT' => SOME_CONST,
'CHECKED' => $opt_flag,
]];
With a new condition I would like to extend this existing array.
if (defined('MODULE_STATUS') && MODULE_STATUS == 'true') {
$arr['JSON_ATTRDATA'] = 1;
}
The result is
Array
(
[0] => Array
(
[ID] => 0
[TEXT] => text
[CHECKED] => 1
)
[JSON_ATTRDATA] => 1
)
What is wrong that the new key is outside of the nestet array?