数组针对某项的求和有关问题

WBOY
Release: 2016-06-13 11:32:41
Original
815 people have browsed it

数组针对某项的求和问题
已知数组a:

<br />array (<br />  0 => <br />  array (<br />    'stock_no' => 'SU13080800340',<br />    'adress' => 'B',<br />    'arr_time' => '2013-08-14 09:00:00',<br />    'c_type' => 'P32E',<br />    'cust_no' => '310F61VA5A',<br />    'mount_total' => '1',<br />    'total' => '16',<br />    'c1_time' => '2013-08-10 15:00:00',<br />    'packageno' => 'CVT121015001',<br />  ),<br />  1 => <br />  array (<br />    'stock_no' => 'SU13080800340',<br />    'adress' => 'B',<br />    'arr_time' => '2013-08-14 09:00:00',<br />    'c_type' => 'P32E',<br />    'cust_no' => '310F61VA5B',<br />    'mount_total' => '2',<br />    'total' => '32',<br />    'c1_time' => '2013-08-10 15:00:00',<br />    'packageno' => 'CVT121015002',<br />  ),<br />  2 => <br />  array (<br />    'stock_no' => 'SU13080800340',<br />    'adress' => 'B',<br />    'arr_time' => '2013-08-14 09:00:00',<br />    'c_type' => 'P32E',<br />    'cust_no' => '310F61VA5B',<br />    'mount_total' => '2',<br />    'total' => '32',<br />    'c1_time' => '2013-08-10 15:00:00',<br />    'packageno' => 'CVT121226001',<br />  ),<br />)<br />
Copy after login


如何分别求得数组中的项cust_no对应的packageno的结果以及stock_no对应mount_total和total项求和的结果?
假设cust_no为310F61VA5A时,对应的packageno为CVT121225001。
    cust_no为310F61VA5B时,对应的packageno为CVT121225002,CVT121226001。

stock_no为SU13080800340时,求得的mount_total结果为3(1+2),total结果为48(16+32)。

如何达到这样的效果?

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