function deletedigui($arr,$value){
if(empty($arr) || !is_array($arr) || empty($value)) return [];
foreach($arr as $key => &$val){
if($val == $value){
unset($arr[$key]);
}
if(is_array($val)){
$val=deletedigui($val,$value);
}
}
return $arr;
}
$arr = ['key1'=>['zjx'],'key2'=>'zjx','key3'=>['key4'=>['key5'=>'zjx','key6'=>'xml']],'key7'=>['zjx','xml'],'key8'=>['key9'=>['key10'=>'zjx','key11'=>['key12'=>'zjx']]]];
var_dump(deletedigui($arr,'zjx'));
网友评论