PHP agregar a la matriz si no existe

$a=array();
// organize the array
foreach($array as $k=>$v){
    foreach($v as $key=>$value){
        if(!in_array($value, $a)){
        	$a[]=$value;
        }
    }
}
Nilesh