怎么把循环中的内容逐个相加

WBOY
Release: 2016-06-13 12:53:22
Original
1079 people have browsed it

如何把循环中的内容逐个相加

<br />
for($counter=$i; $counter>=1; $counter--){<br />
			$weight="weight_$counter";<br />
			$single_price="single_price_$counter";<br />
			$total_price="$_POST[$weight]"*"$_POST[$single_price]";<br />
			$id="id_$counter";<br />
		}<br />
$big_total_price=$total_price+.......;<br />
Copy after login


大概意思就是把每一次for循环中的$total_price进行相加,最后得出来一个总的$big_total_price,这样的话应该怎么写?


------解决方案--------------------
$big_total_price=0;
for($counter=$i; $counter>=1; $counter--){
            $weight="weight_$counter";
            $single_price="single_price_$counter";
            $big_total_price+="$_POST[$weight]"*"$_POST[$single_price]";
            $id="id_$counter";
        }
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