I have array as follows,
$arr['fixed_key'][0]['key1']['key2'] = 'y';
$arr['fixed_key'][1]['key1']['key2'] = 'y';
$arr['fixed_key'][2]['key1']['key2'] = 'n';
$arr['fixed_key'][3]['key1']['key2'] = 'n';
I want to remove all arrays which have key2='n', I can traverse through array in a loop and achieve this, as follows:
$l=length($arr);
for($i=0;$i<$l;$i++) {
if($arr['fixed_key'][$i]['key1']['key2'] == 'n') {
unset($arr['fixed_key'][$i]['key1']['key2']);
}
}
My question is, is it possible to do this in better way, like array_map or array_walk, what is the best possible way?