3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrRes = array( array("2018-08-01"=>"X" , "2018-08-02"=>"O" , "2018-08-03"=>"O" , "2018-08-04"=>"O"), array("2018-08-01"=>"X" , "2018-08-02"=>"X" , "2018-08-03"=>"O" , "2018-08-04"=>"O"), array("2018-08-01"=>"X" , "2018-08-02"=>"X" , "2018-08-03"=>"O" , "2018-08-04"=>"X"), array("2018-08-01"=>"X" , "2018-08-02"=>"O" , "2018-08-03"=>"O" , "2018-08-04"=>"O"), ); $arraySum = ['rows' => ['X'=>[0,0,0,0],'O'=>[0,0,0,0]],'cols' => ['X'=>[0,0,0,0],'O'=>[0,0,0,0]]]; foreach($arrRes as $keyRow => $row){ foreach($row as $keyCol => $col){ $arraySum['rows'][$col][$keyRow]++; $arraySum['cols'][$col][array_search($keyCol,array_keys($row))]++; } } echo "<pre>".print_r($arraySum,1)."</pre>";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 26
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 24
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 24
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 24
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/ROTMP
function name:  (null)
number of ops:  35
compiled vars:  !0 = $arrRes, !1 = $arraySum, !2 = $row, !3 = $keyRow, !4 = $col, !5 = $keyCol
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $8      !0, ->26
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->26
          4    >   ASSIGN                                                   !3, ~9
   13     5      > FE_RESET_R                                       $11     !2, ->24
          6    > > FE_FETCH_R                                       ~12     $11, !4, ->24
          7    >   ASSIGN                                                   !5, ~12
   14     8        FETCH_DIM_RW                                     $14     !1, 'rows'
          9        FETCH_DIM_RW                                     $15     $14, !4
         10        FETCH_DIM_RW                                     $16     $15, !3
         11        PRE_INC                                                  $16
   15    12        INIT_FCALL                                               'array_search'
         13        SEND_VAR                                                 !5
         14        INIT_FCALL                                               'array_keys'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $20     
         17        SEND_VAR                                                 $20
         18        DO_ICALL                                         $21     
         19        FETCH_DIM_RW                                     $18     !1, 'cols'
         20        FETCH_DIM_RW                                     $19     $18, !4
         21        FETCH_DIM_RW                                     $22     $19, $21
         22        PRE_INC                                                  $22
   13    23      > JMP                                                      ->6
         24    >   FE_FREE                                                  $11
   12    25      > JMP                                                      ->3
         26    >   FE_FREE                                                  $8
   19    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !1
         29        SEND_VAL                                                 1
         30        DO_ICALL                                         $24     
         31        CONCAT                                           ~25     '%3Cpre%3E', $24
         32        CONCAT                                           ~26     ~25, '%3C%2Fpre%3E'
         33        ECHO                                                     ~26
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.09 ms | 1396 KiB | 19 Q