快速的数组筛选

//fast filtering values of a array
function fast_array_filter($array,$partten){
$partten = ‘/’ . preg_quote($partten) .’/’;
return preg_grep ($partten, $array);
}
//fast filtering keys of a array
function fast_array_keys_filter($array,$partten){
$partten = ‘/’ . preg_quote($partten) .’/’;
$keys = preg_grep($partten,array_keys($array));
//$retArray = array_combine ($keys , array_fill(0,count($keys),0) );
$retArray = array_flip($keys)
return array_intersect_key($array,$retArray);
}

Posted in 未分类