Blogger Information
Blog 17
fans 0
comment 1
visits 21578
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP 计算二维数组某一列倒数三十条的和
Ant.
Original
491 people have browsed it

实例

$array;
// 第一个参数指定数组 
// 第二个参数start 规定取出元素的开始位置
$lasThirty = array_slice($array, -30); //  -30 指数组倒数30个
$column = array_column($lasThirty, "需要计算的字段"); //获取需要计算的字段,
$result = array_sum($column);  //计算和
return $result;

运行实例 »

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


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