How to insert a new key and value in multidimensional array?
<?
foreach($csmap_data as $key => $csm)
{
$csmap_data[$key]['flag'] = 1;
}
That should do the trick.
You can also do it using php array functions
$csmap_data = array_map(function($arr){
return $arr + ['flag' => 1];
}, $csmap_data);
UPDATE:
to use multiple variables in callback function of array_map
function we can do it by use
$flagValue = 1;
$csmap_data = array_map(function($arr) use ($flagValue){
return $arr + ['flag' => $flagValue];
}, $csmap_data);