欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

数组拆分有关问题

程序员文章站 2022-05-05 20:11:54
...
数组拆分问题
假设数组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',
),


网友评论

文明上网理性发言,请遵守 新闻评论服务协议

我要评论
  • 数组拆分有关问题
  • 专题推荐

    作者信息
    数组拆分有关问题

    认证0级讲师

    推荐视频教程
  • 数组拆分有关问题javascript初级视频教程
  • 数组拆分有关问题jquery 基础视频教程
  • 视频教程分类