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

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

WBOY
WBOYOriginal
2016-06-13 11:23:56862browse

数组求和操作

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


<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 />


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

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