Home > Backend Development > PHP Tutorial > 数组求和操作,该怎么处理

数组求和操作,该怎么处理

WBOY
Release: 2016-06-13 11:23:56
Original
861 people have browsed it

数组求和操作

<br />foreach($a as $k=>$v)<br />{<br />	print_r($newarr);<br />	echo $a[$k]['5'].'<br />';<br />}<br />
Copy after login


<br />Array<br />(<br />    [0] => Array<br />        (<br />            [lotno] => 3206<br />            [count] => 12<br />        )<br /><br />    [1] => Array<br />        (<br />            [lotno] => 3207<br />            [count] => 63<br />        )<br /><br />    [2] => Array<br />        (<br />            [lotno] => 3218<br />            [count] => 180<br />        )<br /><br />)<br />120<br />Array<br />(<br />    [0] => Array<br />        (<br />            [lotno] => 3206<br />            [count] => 12<br />        )<br /><br />    [1] => Array<br />        (<br />            [lotno] => 3207<br />            [count] => 63<br />        )<br /><br />    [2] => Array<br />        (<br />            [lotno] => 3218<br />            [count] => 180<br />        )<br /><br />)<br />135<br />
Copy after login


将count相加,如果对应行的结果为120,则显示3206*12 3207*63 3218*45
若对应行的结果为135,则显示3218*135 (135=180-45(上一轮count已用的45),不够则补齐)

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