3v4l.org

run code in 300+ 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 getCustomMonoRecords($data){ $res = []; foreach($data as $m=>$ar){ $res[$m] = []; $tmp = []; $i = 0; foreach($ar as $ind=>$rec){ if(!array_key_exists($rec['id'],$tmp)) { $tmp[$rec['id']] = $i; $res[$m][$i] = $rec; $i++; } else { $in = $tmp[$rec['id']]; $res[$m][$in]['monthly_rental'] += $rec['monthly_rental']; $res[$m][$in]['arc'] += $rec['arc']; } } } return $res; } $res = getCustomMonoRecords($data); print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YEjft
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>
  158     1        INIT_FCALL                                               'getcustommonorecords'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
  159     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

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

End of function getcustommonorecords

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.22 ms | 1005 KiB | 15 Q