3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( "0" => array( "id" => 1, "ip" => "10.40.47.5", "visited_ip" => "10.40.40.10", "quota" => 20, ), "1" => array( "id" => 2, "ip" => "10.40.47.20", "visited_ip" => "10.40.40.10", "quota" => 10, ), "2" => array( "id" => 1, "ip" => "10.40.47.5", "visited_ip" => "10.40.40.10", "quota" => 30, ) ); foreach($array as $item){ if(!isset($res[$item['id'] . ' ' . $item['ip']])){ $res[$item['id'] . ' ' . $item['ip']] = $item; }else{ $res[$item['id'] . ' ' . $item['ip']]['quota'] += $item['quota']; } } $res = array_values($res); var_dump($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 26
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 26
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/5PDXp
function name:  (null)
number of ops:  35
compiled vars:  !0 = $array, !1 = $item, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1      > FE_RESET_R                                       $4      !0, ->26
          2    > > FE_FETCH_R                                               $4, !1, ->26
   25     3    >   FETCH_DIM_R                                      ~5      !1, 'id'
          4        CONCAT                                           ~6      ~5, '+'
          5        FETCH_DIM_R                                      ~7      !1, 'ip'
          6        CONCAT                                           ~8      ~6, ~7
          7        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !2, ~8
          8        BOOL_NOT                                         ~10     ~9
          9      > JMPZ                                                     ~10, ->17
   26    10    >   FETCH_DIM_R                                      ~11     !1, 'id'
         11        CONCAT                                           ~12     ~11, '+'
         12        FETCH_DIM_R                                      ~13     !1, 'ip'
         13        CONCAT                                           ~14     ~12, ~13
         14        ASSIGN_DIM                                               !2, ~14
         15        OP_DATA                                                  !1
   25    16      > JMP                                                      ->25
   28    17    >   FETCH_DIM_R                                      ~16     !1, 'id'
         18        CONCAT                                           ~17     ~16, '+'
         19        FETCH_DIM_R                                      ~18     !1, 'ip'
         20        CONCAT                                           ~19     ~17, ~18
         21        FETCH_DIM_R                                      ~22     !1, 'quota'
         22        FETCH_DIM_RW                                     $20     !2, ~19
         23        ASSIGN_DIM_OP                +=               1          $20, 'quota'
         24        OP_DATA                                                  ~22
   24    25    > > JMP                                                      ->2
         26    >   FE_FREE                                                  $4
   31    27        INIT_FCALL                                               'array_values'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $23     
         30        ASSIGN                                                   !2, $23
   32    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !2
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.12 ms | 1004 KiB | 15 Q