Home >Backend Development >PHP Tutorial > 数组拆分有关问题

数组拆分有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:37:04821browse

数组拆分问题
假设数组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 />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn