Home >Backend Development >PHP Tutorial > 数组加减有关问题

数组加减有关问题

WBOY
WBOYOriginal
2016-06-13 12:39:18860browse

数组加减问题
已知数组a和b。

<br />
//数组a:<br />
array (<br />
  0 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '2X15',<br />
    'part_count' => '32',<br />
  ),<br />
  1 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '2Z25',<br />
    'part_count' => '32',<br />
  ),<br />
)<br />
<br />
//数组b:<br />
<br />
array (<br />
  0 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'total' => '48',<br />
  ),<br />
)<br />


数组a cust_no为310F6 1VA5A时,对应的总量是32+32=64,数组b cust_no为310F6 1VA5A时对应的总量是48。
想求得数组b总量为48时,对应数组a中的哪些内容?数组a剩余的结果是多少?

以这个例子来说,
得到数组a的结果:
<br />
//数组a:<br />
array (<br />
  0 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '2X15',<br />
    'part_count' => '32',<br />
  ),<br />
  1 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '2Z25',<br />
    'part_count' => '16',<br />
  ),<br />
)<br />

剩余数组a的结果:
<br />
//数组a:<br />
array (<br />
  0 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '2X15',<br />
    'part_count' => '0',<br />
  ),<br />
  1 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '2Z25',<br />
    'part_count' => '16',<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