This tutorial briefly describes the use of the numeric data in the statistical array in PHP and the function array_sum ().
Example 1
The code is as follows:
| The code is as follows |
Copy Code |
|
$a =array (0=> "5",1=> ",2=>" 25 ");
echo array_sum ($a);
?>
Output:
45 |
Example 2
The code is as follows:
| The code is as follows |
Copy Code |
|
$a =array (0=>5,1=>15,2=>25);
echo array_sum ($a);
?>
Output:
45 |
Example 3
The code is as follows:
| The code is as follows |
Copy Code |
|
$a =array (0=>5,1=>15.5,2=>25);
echo array_sum ($a);
?>
Output:
45.5 |
Example 4
The code is as follows:
| The code is as follows |
Copy Code |
|
$a =array (0=>5,1=> "15s", 2=>25);
echo array_sum ($a);
?>
Output:
45 |
Example 5
The code is as follows:
| The code is as follows |
Copy Code |
|
$a =array (0=>5,1=> "s15s", 2=>25);
echo array_sum ($a);
?>
Output:
30 |
http://www.bkjia.com/PHPjc/631313.html www.bkjia.com true http://www.bkjia.com/PHPjc/631313.html techarticle This tutorial briefly describes the use of the numeric data in the statistical array in PHP and the function array_sum (). Example 1 code is as follows: code to copy Code as follows? PHP $a =array (0= ...