Recursive filtering array in php

$json = $q->execute(array(),Doctrine::HYDRATE_ARRAY);
$filter_key_array = array(‘is_enabled’,’sortorder’,’deleted_at’,’is_deleted’);

$this->sanitizeJson(&$json[0], $filter_key_array);

————
public function sanitizeJson($array,$filter_key_array){
foreach($array as $key => &$value){
if(is_array($value)){
$value = $this->sanitizeJson($value, $filter_key_array);
}else{
if(in_array($key, $filter_key_array)){
unset($array[$key]);
}
}
}
return $array;
}

Advertisements