<?php //去除多维数组中的空值 $arr1 = array("1","","2"); $arr2 = array("","3","4"); $arr3 = array("","5",""); $arr4 = array("11","","22"); $arr5 = array("","33","44"); $arr6 = array("","55",""); $arr7 = array("111","","222"); $arr8 = array("","333","444"); $arr9 = array("","555",""); $s_arr1 = array("0"=>$arr1,"1"=>$arr2,"2"=>$arr3); $s_arr2 = array("0"=>$arr4,"1"=>$arr5,"2"=>$arr6); $s_arr3 = array("0"=>$arr7,"1"=>$arr8,"2"=>$arr9); $big_arr = array("0"=>$s_arr1,"1"=>$s_arr2,"2"=>$s_arr3); $g_arr = get_arr($big_arr); print_r($g_arr); function get_arr($arr) { foreach ($arr as $k=>$v) { if(is_array($arr[$k])) { $arr[$k] = get_arr($arr[$k]); } else { if(empty($arr[$k])) { unset($arr[$k]); } } } return $arr; } ?>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。