<?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; } ?>
点击查看更多内容
1人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦