This tutorial briefly describes how to use the array_sum () function and the statistical array of numeric data in php. Example 1: The code is as follows: & lt ;? Php $ aarray (0 & gt; & quot; 5 & quot;, 1 & gt; & quot; 15 & quot;, 2 & gt; & quot;
This tutorial briefly describes how to use the array_sum () function and the statistical array of numeric data in php.
Example 1: The code is as follows:
- $ A = array (0 => "5", 1 => "15", 2 => "25 ");
- Echo array_sum ($ );
- ?>
- // Output: 45
Example 2: The code is as follows:
- $ A = array (0 => 5, 1 => 15, 2 => 25 );
- Echo array_sum ($ );
- ?>
- // Output: 45
Example 3: The code is as follows:
- $ A = array (0 => 5, 1 => 15.5, 2 => 25 );
- Echo array_sum ($ );
- ?>
- // Output: 45.5
Example 4: The code is as follows:
- $ A = array (0 => 5, 1 => "15 s", 2 => 25 );
- Echo array_sum ($ );
- ?>
- // Output: 45
Example 5: The code is as follows:
- $ A = array (0 => 5, 1 => "s15s", 2 => 25 );
- Echo array_sum ($ );
- ?>
- // Output: 30