3v4l.org

run code in 500+ PHP versions simultaneously
<?php $rows = [ ['3', '2022-01-03'], ['5,3', '2022-01-15'], ['4', '2022-01-27'], ['5', '2022-02-01'], ['7', '2022-02-09'], ['3,2', '2022-01-16'], ]; $counts = []; foreach($rows as $row){ $ids = explode(',', $row[0]); $month = date('m', strtotime($row[1])); foreach($ids as $id){ if(!array_key_exists($id, $counts)){ $counts[$id] = []; } if(!array_key_exists($month, $counts[$id])){ $counts[$id][$month] = 0; } $counts[$id][$month]++; } } var_dump($counts);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 39
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 39
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 37
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 37
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 33
Branch analysis from position: 26
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 37
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/mVaBB
function name:  (null)
number of ops:  44
compiled vars:  !0 = $rows, !1 = $counts, !2 = $row, !3 = $ids, !4 = $month, !5 = $id
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   12     1        ASSIGN                                                       !1, <array>
   13     2      > FE_RESET_R                                           $8      !0, ->39
          3    > > FE_FETCH_R                                                   $8, !2, ->39
   14     4    >   INIT_FCALL                                                   'explode'
          5        SEND_VAL                                                     '%2C'
          6        FETCH_DIM_R                                          ~9      !2, 0
          7        SEND_VAL                                                     ~9
          8        DO_ICALL                                             $10     
          9        ASSIGN                                                       !3, $10
   15    10        INIT_FCALL                                                   'date'
         11        SEND_VAL                                                     'm'
         12        INIT_FCALL                                                   'strtotime'
         13        FETCH_DIM_R                                          ~12     !2, 1
         14        SEND_VAL                                                     ~12
         15        DO_ICALL                                             $13     
         16        SEND_VAR                                                     $13
         17        DO_ICALL                                             $14     
         18        ASSIGN                                                       !4, $14
   16    19      > FE_RESET_R                                           $16     !3, ->37
         20    > > FE_FETCH_R                                                   $16, !5, ->37
   17    21    >   ARRAY_KEY_EXISTS                                     ~17     !5, !1
         22        BOOL_NOT                                             ~18     ~17
         23      > JMPZ                                                         ~18, ->26
   18    24    >   ASSIGN_DIM                                                   !1, !5
         25        OP_DATA                                                      <array>
   20    26    >   FETCH_DIM_R                                          ~20     !1, !5
         27        ARRAY_KEY_EXISTS                                     ~21     !4, ~20
         28        BOOL_NOT                                             ~22     ~21
         29      > JMPZ                                                         ~22, ->33
   21    30    >   FETCH_DIM_W                                          $23     !1, !5
         31        ASSIGN_DIM                                                   $23, !4
         32        OP_DATA                                                      0
   24    33    >   FETCH_DIM_RW                                         $25     !1, !5
         34        FETCH_DIM_RW                                         $26     $25, !4
         35        PRE_INC                                                      $26
   16    36      > JMP                                                          ->20
         37    >   FE_FREE                                                      $16
   13    38      > JMP                                                          ->3
         39    >   FE_FREE                                                      $8
   28    40        INIT_FCALL                                                   'var_dump'
         41        SEND_VAR                                                     !1
         42        DO_ICALL                                                     
         43      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.09 ms | 1911 KiB | 17 Q