ArticleDirectory
Introduction: This is a detailed page of array_sum () in [PHP Array Function Sequence]. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 361699 'scrolling = 'no'> array_sum () Definition and usage
The array_sum () function returns the sum of all values in the array.
If all values are integers, an integer is returned. If one or more of the values are floating-point numbers, the return value is floating-point numbers.
In versions earlier than PhP 4.2.1, the input array itself is modified to convert the string value to a value (in most cases, it is converted to zero, depending on the specific system ).
Syntax
Array_sum (array)
| Parameters |
Description |
| Array |
Required. Specifies the input array. |
Example 1
<? PHP $ A = array (0 => "5", 1 => "15", 2 => "25"); echo array_sum ($ A);?>
Output:
45
Example 2
<? PHP $ A = array (0 => 5, 1 => 15, 2 => 25); echo array_sum ($ A);?>
Output:
45
Example 3
<? PHP $ A = array (0 => 5, 1 => 15.5, 2 => 25); echo array_sum ($ A);?>
Output:
45.5
Example 4
<? PHP $ A = array (0 => 5, 1 => "15 s", 2 => 25); echo array_sum ($ A);?>
Output:
45
Example 5
<? PHP $ A = array (0 => 5, 1 => "s15s", 2 => 25); echo array_sum ($ A);?>
Output:
30
Source: http://www.cnblogs.com/zhouisizhi/
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/361699.html pageno: 1.