3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = Array ( 0 => Array ( 0 => Array ( "id" => 521, "full_name" => "Nilesh chauhan", "monthly_rental" => 15000, "arc" => 180000, "month" => 1 ) ), 1 => Array ( 0 => Array ( "id" => 1549, "full_name" => "Ritesh shah", "monthly_rental" => 14166.666666667, "arc" => 170000, "month" => 2, ), 1 => Array ( "id" => 589, "full_name" => "Gajanan satpute", "monthly_rental" => 14166.666666667, "arc" => 170000, "month" => 2, ), 2 => Array ( "id" => 521, "full_name" => "Nilesh chauhan", "monthly_rental" => 13333.333333333, "arc" => 160000, "month" => 2, ), 3 => Array ( "id" => 1549, "full_name" => "Ritesh shah", "monthly_rental" => 11250, "arc" => 135000, "month" => 2, ), 4 => Array ( "id" => 521, "full_name" => "Nilesh chauhan", "monthly_rental" => 7500, "arc" => 90000, "month" => 2, ), 5 => Array ( "id" => 1549, "full_name" => "Ritesh shah", "monthly_rental" => 7000, "arc" => 84000, "month" => 2, ), ), 2 => Array ( 0 => Array ( "id" => 1549, "full_name" => "Ritesh shah", "monthly_rental" => 35833.333333333, "arc" => 430000, "month" => 3, ), 1 => Array ( "id" => 1549, "full_name" => "Ritesh shah", "monthly_rental" => 14166.666666667, "arc" => 170000, "month" => 3, ), 2 => Array ( "id" => 521, "full_name" => "Nilesh chauhan", "monthly_rental" => 13333.333333333, "arc" => 160000, "month" => 3, ), 3 => Array ( "id" => 521, "full_name" => "Nilesh chauhan", "monthly_rental" => 8750, "arc" => 105000, "month" => 3, ), 4 => Array ( "id" => 589, "full_name" => "Gajanan satpute", "monthly_rental" => 7500, "arc" => 90000, "month" => 3, ), 5 => Array ( 'id' => 1549, "full_name" => "Ritesh shah", "monthly_rental" => 6493.3333333333, "arc" => 77920, "month" => 3, ) ) ); function getCustomMonoRecords2($data){ $res = []; foreach($data as $m=>$ar){ $res[$m] = []; foreach($ar as $ind=>$rec){ if(!isset($res[$m][$rec['id']])){ $res[$m][$rec['id']] = $rec; } else { $res[$m][$rec['id']]['monthly_rental'] += $rec['monthly_rental']; $res[$m][$rec['id']]['arc'] += $rec['arc']; } } $res[$m] = array_values($res[$m]); } return $res; } $res = getCustomMonoRecords2($data); print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4VXhv
function name:  (null)
number of ops:  9
compiled vars:  !0 = $data, !1 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
  154     1        INIT_FCALL                                                   'getcustommonorecords2'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $3      
          4        ASSIGN                                                       !1, $3
  155     5        INIT_FCALL                                                   'print_r'
          6        SEND_VAR                                                     !1
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function getcustommonorecords2:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 41
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 41
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 33
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 33
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 33
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/4VXhv
function name:  getCustomMonoRecords2
number of ops:  44
compiled vars:  !0 = $data, !1 = $res, !2 = $ar, !3 = $m, !4 = $rec, !5 = $ind
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  135     0  E >   RECV                                                 !0      
  137     1        ASSIGN                                                       !1, <array>
  139     2      > FE_RESET_R                                           $7      !0, ->41
          3    > > FE_FETCH_R                                           ~8      $7, !2, ->41
          4    >   ASSIGN                                                       !3, ~8
  140     5        ASSIGN_DIM                                                   !1, !3
          6        OP_DATA                                                      <array>
  141     7      > FE_RESET_R                                           $11     !2, ->33
          8    > > FE_FETCH_R                                           ~12     $11, !4, ->33
          9    >   ASSIGN                                                       !5, ~12
  142    10        FETCH_DIM_R                                          ~15     !4, 'id'
         11        FETCH_DIM_IS                                         ~14     !1, !3
         12        ISSET_ISEMPTY_DIM_OBJ                             0  ~16     ~14, ~15
         13        BOOL_NOT                                             ~17     ~16
         14      > JMPZ                                                         ~17, ->20
  143    15    >   FETCH_DIM_R                                          ~19     !4, 'id'
         16        FETCH_DIM_W                                          $18     !1, !3
         17        ASSIGN_DIM                                                   $18, ~19
         18        OP_DATA                                                      !4
  142    19      > JMP                                                          ->32
  145    20    >   FETCH_DIM_R                                          ~22     !4, 'id'
         21        FETCH_DIM_R                                          ~25     !4, 'monthly_rental'
         22        FETCH_DIM_RW                                         $21     !1, !3
         23        FETCH_DIM_RW                                         $23     $21, ~22
         24        ASSIGN_DIM_OP                    +=               1          $23, 'monthly_rental'
         25        OP_DATA                                                      ~25
  146    26        FETCH_DIM_R                                          ~27     !4, 'id'
         27        FETCH_DIM_R                                          ~30     !4, 'arc'
         28        FETCH_DIM_RW                                         $26     !1, !3
         29        FETCH_DIM_RW                                         $28     $26, ~27
         30        ASSIGN_DIM_OP                    +=               1          $28, 'arc'
         31        OP_DATA                                                      ~30
  141    32    > > JMP                                                          ->8
         33    >   FE_FREE                                                      $11
  149    34        INIT_FCALL                                                   'array_values'
         35        FETCH_DIM_R                                          ~32     !1, !3
         36        SEND_VAL                                                     ~32
         37        DO_ICALL                                             $33     
         38        ASSIGN_DIM                                                   !1, !3
         39        OP_DATA                                                      $33
  139    40      > JMP                                                          ->3
         41    >   FE_FREE                                                      $7
  151    42      > RETURN                                                       !1
  152    43*     > RETURN                                                       null

End of function getcustommonorecords2

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.59 ms | 2475 KiB | 16 Q