首页 > 后端开发 > php教程 > 数组拆分有关问题

数组拆分有关问题

WBOY
发布: 2016-06-13 12:37:04
原创
799 人浏览过

数组拆分问题
假设数组a:

array (<br />
  0 => <br />
  array (<br />
    'po_num' => 'DYNP-770266110-00',<br />
    'plant' => 'DYNP',<br />
    'get_date' => '2013-09-09',<br />
    'cust_no' => '12647212',<br />
    'total' => '60',<br />
    'snp' => '15',<br />
    'mount' => '4',<br />
    'lp_no' => 'P000000D',<br />
  ),<br />
  1 => <br />
  array (<br />
    'po_num' => 'DYNP-770266110-00',<br />
    'plant' => 'DYNP',<br />
    'get_date' => '2013-09-09',<br />
    'cust_no' => '12654172',<br />
    'total' => '615',<br />
    'snp' => '15',<br />
    'mount' => '41',<br />
    'lp_no' => 'P000000D',<br />
  ),<br />
)
登录后复制


当满足整个total为一定条件时,将数组拆分开来。例中total为675,假设拆分条件为total满足225,也就是拆分为3个数组,如何能将数组拆分成这样?
<br />
//b<br />
array (<br />
  0 => <br />
  array (<br />
    'po_num' => 'DYNP-770266110-00',<br />
    'plant' => 'DYNP',<br />
    'get_date' => '2013-09-09',<br />
    'cust_no' => '12647212',<br />
    'total' => '60',<br />
    'snp' => '15',<br />
    'mount' => '4',<br />
    'lp_no' => 'P000000D',<br />
  ),<br />
  1 => <br />
  array (<br />
    'po_num' => 'DYNP-770266110-00',<br />
    'plant' => 'DYNP',<br />
    'get_date' => '2013-09-09',<br />
    'cust_no' => '12654172',<br />
    'total' => '165',<br />
    'snp' => '15',<br />
    'mount' => '11',<br />
    'lp_no' => 'P000000D',<br />
  ),<br />
)<br />
//c<br />
array (<br />
  0 => <br />
  array (<br />
    'po_num' => 'DYNP-770266110-00',<br />
    'plant' => 'DYNP',<br />
    'get_date' => '2013-09-09',<br />
    'cust_no' => '12647212',<br />
    'total' => '225',<br />
    'snp' => '15',<br />
    'mount' => '15',<br />
    'lp_no' => 'P000000D',<br />
  ),<br />
)<br />
//d<br />
array (<br />
  0 => <br />
  array (<br />
    'po_num' => 'DYNP-770266110-00',<br />
    'plant' => 'DYNP',<br />
    'get_date' => '2013-09-09',<br />
    'cust_no' => '12647212',<br />
    'total' => '225',<br />
    'snp' => '15',<br />
    'mount' => '15',<br />
    'lp_no' => 'P000000D',<br />
  ),<br />
)<br />
登录后复制

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板