Php post Array Method

Source: Internet
Author: User




How can I describe such a sentence? Help, online, etc.



$ Num = $ _ POST ['v1 '] + $ _ POST ['v2'] + $ _ POST ['v3'] + $ _ POST ['v4 '] + $ _ POST ['v5 '] + $ _ POST ['v6'] + $ _ POST ['v7'] + $ _ POST ['v8 '] + $ _ POST [' v9'] + $ _ POST ['v10'];

Echo $ num;
How can I abbreviated this sentence to copy the code?
Don't want to fight so much


Best Answer [url = http://www.111cn.cn/bbs/space.php? Username = microwind] link tag microwind [/url]
[Url = http://www.111cn.cn/bbs/space.php? Uid = 39178] link tag [img] http://www.111cn.cn/server/avatar.php? Uid = 39178 & size = small [/img] [/url]

For ($ I = 1; $ I <11; $ I ++ ){
$ Temp [] = $ _ POST ['V'. $ I];
}
Echo array_sum ($ temp );

???? It seems very troublesome... I don't know ..

If $ _ POST contains only a few of them, you can
Echo array_sum ($ _ POST );



Other solutions


For ($ I = 1; $ I <11; $ I ++ ){
$ Temp [] = $ _ POST ['V'. $ I];
}
Echo array_sum ($ temp );

???? It seems very troublesome... I don't know ..

If $ _ POST contains only a few of them, you can
Echo array_sum ($ _ POST );

Other solutions


Array_sum ($ _ POST []);
Sum the Global Array

Other solutions
Array_sum ($ _ POST []);
Sum the Global Array
Iminto posted at [url = http://bbs.111cn.cn/redirect.php? Goto = findpost & pid = 993037 & ptid = 118194] link mark [img] http://bbs.111cn.cn/images/common/back.gif?/img=#/url]
Array_sum ($ _ POST []);
How to use it?

Other solutions
[Url = Response

Other solutions
Array_sum ($ _ POST []);
How to use it?
Zyyr365 published on [url = http://bbs.111cn.cn/redirect.php? Goto = findpost & pid = 993040 & ptid = 118194] link mark [img] http://bbs.111cn.cn/images/common/back.gif?/img=#/url]
[Img] http://www.111cn.cn/bbs/images/smilies/default/02.gif#/img]
That's how it works. This is a function ......

Other solutions
Array_sum -- calculate the sum of all values in the array
Description
Number array_sum (array)
Array_sum () returns the sum of all values in the array as an integer or floating point number.

In this case, we get the data in the array, and then...
Understand how to try ~

Other solutions
I came up with another method.
For ($ I = 1; $ I <= 10; $ I ++ ){
$ Num + = $ _ POST ['V'. $ I];
}
Echo $ num;


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.