二个数组相加,将一个数组写入另一个数组

WBOY
Release: 2016-06-13 12:38:51
Original
1013 people have browsed it

2个数组相加,将一个数组写入另一个数组
已知数组a和数组b:

//数组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' => '5',<br />
  ),<br />
)<br />
<br />
//数组b:<br />
<br />
array (<br />
  0 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '2Z15',<br />
    'part_count' => '100',<br />
  ),<br />
  1 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '3115',<br />
    'part_count' => '28',<br />
  ),<br />
)
Copy after login


把数组b的结果加入数组a,同cust_no,lotno对应的part_count累加。变成这样的结果:
<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' => '2Z15',<br />
    'part_count' => '105',<br />
  ),<br />
  2 => <br />
  array (<br />
    'cust_no' => '310F6 1VA5A',<br />
    'lotno' => '3115',<br />
    'part_count' => '28',<br />
  ),<br />
)<br />
Copy after login

这样如何做到?需要用哪些数组函数?谢谢!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template