I want to unset a field of a two-dimensional array. I got a function like this, but it doesn’t work:
function excludeOldScreeningDate($array){
foreach($array as $val){
if($val['ref'] == 'G'){
unset($val['screening_date']);
}
}
return $array;
}
You should pass elements of an array by reference:
Notice the
foreach($array as &$val){line has changed.