数组拆分有关问题
程序员文章站
2022-05-05 20:11:54
...
数组拆分问题
假设数组a:
当满足整个total为一定条件时,将数组拆分开来。例中total为675,假设拆分条件为total满足225,也就是拆分为3个数组,如何能将数组拆分成这样?
假设数组a:
array (
0 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12647212',
'total' => '60',
'snp' => '15',
'mount' => '4',
'lp_no' => 'P000000D',
),
1 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12654172',
'total' => '615',
'snp' => '15',
'mount' => '41',
'lp_no' => 'P000000D',
),
)
当满足整个total为一定条件时,将数组拆分开来。例中total为675,假设拆分条件为total满足225,也就是拆分为3个数组,如何能将数组拆分成这样?
//b
array (
0 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12647212',
'total' => '60',
'snp' => '15',
'mount' => '4',
'lp_no' => 'P000000D',
),
1 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12654172',
'total' => '165',
'snp' => '15',
'mount' => '11',
'lp_no' => 'P000000D',
),
)
//c
array (
0 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12647212',
'total' => '225',
'snp' => '15',
'mount' => '15',
'lp_no' => 'P000000D',
),
)
//d
array (
0 =>
array (
'po_num' => 'DYNP-770266110-00',
'plant' => 'DYNP',
'get_date' => '2013-09-09',
'cust_no' => '12647212',
'total' => '225',
'snp' => '15',
'mount' => '15',
'lp_no' => 'P000000D',
),
)
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
- 最新文章
- 热门排行
上一篇: Nodejs的form验证及图片上传
下一篇: Java中关于项目安全处理的方法分享
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论