过滤函数

function my_filter($arr){
    $filterDatum = 'what you set';
    
    foreach($arr as $k => &$item){
        if(is_array($item){
            my_filter($item);
        }else{ // item is an element
            if($item == $filterDatum){
                unset($arr[$k]);
            }
        }
    }
    
    return $arr;
}

过滤实现语句

$arr = [
    // who know what the array looks like.
];

$arr = array_filter($arr, 'my_filter');

BINGO

参考

  1. 本站问答


niecprea
871 声望54 粉丝

Hello world!