一个数组算法问题,三维数组,怎么排除掉在第一层的每个数组里面的子数组里面每个元素的sk_id连续8条为空的数组去除掉?
如果,大数组里面的子数组每个元素里面有连续8个子元素的sk_id为空的则去掉这子数组。数据打印后如下:
array(100) {
[0] =array(88){
[0] => array(8) {
["email"] => string(19) "13537951319@163.com"
["sno"] => string(15) "106725097310815"
["class_id"] => string(3) "559"
["user_id"] => string(4) "6648"
["date_time"] => string(10) "1473159600"
["classname"] => string(15) "呵呵呵呵呵"
["sk_id"] => NULL
["num"] => int(0)
}
[1] => array(8) {
["email"] => string(19) "13537951319@163.com"
["sno"] => string(15) "106725097310815"
["class_id"] => string(3) "559"
["user_id"] => string(4) "6648"
["date_time"] => string(10) "1473150900"
["classname"] => string(15) "呵呵呵呵呵"
["sk_id"] => NULL
["num"] => int(1)
}
[2] => array(8) {
["email"] => string(19) "13537951319@163.com"
["sno"] => string(15) "106725097310815"
["class_id"] => string(3) "559"
["user_id"] => string(4) "6648"
["date_time"] => string(10) "1473147900"
["classname"] => string(15) "呵呵呵呵呵"
["sk_id"] => NULL
["num"] => int(2)
}
[3] => array(8) {
["email"] => string(19) "13537951319@163.com"
["sno"] => string(15) "106725097310815"
["class_id"] => string(3) "559"
["user_id"] => string(4) "6648"
["date_time"] => string(10) "1473144600"
["classname"] => string(15) "呵呵呵呵呵"
["sk_id"] => NULL
["num"] => int(3)
}
....
},
[1] =array(88){
[0] => array(8) {
["email"] => string(19) "13537951319@163.com"
["sno"] => string(15) "106725097310815"
["class_id"] => string(3) "559"
["user_id"] => string(4) "6648"
["date_time"] => string(10) "1473159600"
["classname"] => string(15) "呵呵呵呵呵"
["sk_id"] => NULL
["num"] => int(0)
}
[1] => array(8) {
["email"] => string(19) "13537951319@163.com"
["sno"] => string(15) "106725097310815"
["class_id"] => string(3) "559"
["user_id"] => string(4) "6648"
["date_time"] => string(10) "1473150900"
["classname"] => string(15) "呵呵呵呵呵"
["sk_id"] => NULL
["num"] => int(1)
}
[2] => array(8) {
["email"] => string(19) "13537951319@163.com"
["sno"] => string(15) "106725097310815"
["class_id"] => string(3) "559"
["user_id"] => string(4) "6648"
["date_time"] => string(10) "1473147900"
["classname"] => string(15) "呵呵呵呵呵"
["sk_id"] => NULL
["num"] => int(2)
}
[3] => array(8) {
["email"] => string(19) "13537951319@163.com"
["sno"] => string(15) "106725097310815"
["class_id"] => string(3) "559"
["user_id"] => string(4) "6648"
["date_time"] => string(10) "1473144600"
["classname"] => string(15) "呵呵呵呵呵"
["sk_id"] => NULL
["num"] => int(3)
}
....
}
....
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你看下这样可以吗
写了一个简单的小例子,连续重复三个,去掉子数组。
数组:
代码:
输出:
你看看这个思路,我没有做测试