Array ( [id] => 10004 [naem] => 学校 [information] => [user] => Array ( [0] => Array ( [id] => 20001 [name] => lin [pass] => ybzzax [age] => 19 [group_id] => 10004 [house] => Array ( [0] => Array ( [id] => 1 [name] => 小明 [tel] => 2147483647 [user_id] => 20001 ) ) ) [1] => Array ([id] => 20002 [name] => dong [pass] => ybzzam [age] => 19 [group_id] => 10004 [house] => Array ( [0] => Array ( [id] => 2 [name] => 小红 [tel] => 2147483647 [user_id] => 20002 ) ) ) [2] => Array ( [id] => 20003 [name] => tian [pass] => ybzzan [age] => 19 [group_id] => 10004 [house] => Array ( [0] => Array ( [id] => 3 [name] => 小白 [tel] => 2147483647 [user_id] => 20003 ) ) ) [3] => Array ( [id] => 20004 [name] => chi [pass] => ybzzar [age] => 19 [group_id] => 10004 [house] => Array ( [0] => Array ( [id] => 4 [name] => 小东 [tel] => 2147483647 [user_id] => 20004 ) ) ) ) )//$array是返回的数据 $character是要消除的字段public function dataHandle($array=[],$character=[]){ foreach ($array as $key=>$arrValue) { foreach ($character as $value){ if (!is_array($arrValue)&&array_key_exists($value,$array)) { if($key==$value){ unset($array[$key]); } break; }else{ if(!is_array($arrValue)){ continue; }else{ $this->dataHandle($arrValue,$character); } } }为什么unset没用最终还是原来的数据
添加回答
举报
0/150
提交
取消