php 取最后一个值

int(1)
string(1) "3"
array(3) {
  ["key"]=>
  string(8) "19314771"
  ["doc_count"]=>
  int(2)
  ["end_battle"]=>
  array(3) {
    ["doc_count_error_upper_bound"]=>
    int(0)
    ["sum_other_doc_count"]=>
    int(0)
    ["buckets"]=>
    array(2) {
      [0]=>
      array(2) {
        ["key"]=>
        string(2) "2
"
        ["doc_count"]=>
        int(1)
      }
      [1]=>
      array(2) {
        ["key"]=>
        string(2) "3
"
        ["doc_count"]=>
        int(1)
      }
    }
  }
}
int(1)
string(1) "3"
array(3) {
  ["key"]=>
  string(8) "19059941"
  ["doc_count"]=>
  int(1)
  ["end_battle"]=>
  array(3) {
    ["doc_count_error_upper_bound"]=>
    int(0)
    ["sum_other_doc_count"]=>
    int(0)
    ["buckets"]=>
    array(1) {
      [0]=>
      array(2) {
        ["key"]=>
        string(2) "2
"
        ["doc_count"]=>
        int(1)
      }
    }
  }
}
int(0)
string(1) "2"
array(3) {
  ["key"]=>
  string(8) "19213271"
  ["doc_count"]=>
  int(1)
  ["end_battle"]=>
  array(3) {
    ["doc_count_error_upper_bound"]=>
    int(0)
    ["sum_other_doc_count"]=>
    int(0)
    ["buckets"]=>
    array(1) {
      [0]=>
      array(2) {
        ["key"]=>
        string(2) "2
"
        ["doc_count"]=>
        int(1)
      }
    }
  }
}
int(0)
string(1) "2"
array(3) {
  ["key"]=>
  string(8) "19225631"
  ["doc_count"]=>
  int(1)
  ["end_battle"]=>
  array(3) {
    ["doc_count_error_upper_bound"]=>
    int(0)
    ["sum_other_doc_count"]=>
    int(0)
    ["buckets"]=>
    array(1) {
      [0]=>
      array(2) {
        ["key"]=>
        string(2) "2
"
        ["doc_count"]=>
        int(1)
      }
    }
  }
}
 foreach($response['aggregations']['days']['buckets'] as $v){

                       
                         $c = count($v['end_battle']['buckets'])-1;

                         $b = trim($v['end_battle']['buckets'][$c]["key"]);

                         $r[$b] = array_key_exists($b,$r) ? (int)$r[$b]+1 : 1;

                }

        exit;
           reset($r);
           foreach($r as $key=>$val){
                        $res['time'] = date("Y-m-d",$item['stime']);
                        $res['match'] = $key;
                        $res['num'] = $val;
                        $tmp[]=$res;
           }

array(2) {
  [0]=>
  array(3) {
    ["time"]=>
    string(10) "2020-01-11"
    ["match"]=>
    int(3)
    ["num"]=>
    int(7)
  }
  [1]=>
  array(3) {
    ["time"]=>
    string(10) "2020-01-11"
    ["match"]=>
    int(2)
    ["num"]=>
    int(5)
  }
}
  $b = $v['end_battle']['buckets'][$c];
  var_dump($b);
array(2) {
  ["key"]=>
  string(2) "3
"
  ["doc_count"]=>
  int(1)
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

伟伟哦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值