Blogger Information
Blog 250
fans 3
comment 0
visits 321794
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
数组函数:array_sum() 的用法
梁凯达的博客
Original
1145 people have browsed it

 //array_sum()
 //函数用于返回数组的值得总和
 //参数为要累加的数组
 //返回值为要计算出来的总和

实例

$arr = array(1,2,3,4,5,6,7);
 $arr_sum  = array_sum($arr);
 var_dump($arr_sum);
 //用自定义函数完成   arr_sum的方法
 echo '<hr />'; 
 //定义一个自定义函数
  function sum($arr){
   $sum = 0;
   foreach($arr as $val){
    $sum += $val;
  }
  echo $sum;
  }
  sum($arr);

运行实例 »

点击 "运行实例" 按钮查看在线实例

 

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post