3v4l.org

run code in 300+ PHP versions simultaneously
<?php $results = [ "User_1" => [ "Step_1" => "accepted", "Step_2" => "accepted", "Step_3" => "waiting" ], "User_2" => [ "Step_1" => "waiting", "Step_2" => "accepted", "Step_3" => "accepted" ], "User_3" => [ "Step_1" => "refused", "Step_2" => "refused", "Step_3" => "waiting" ] ]; $steps = []; $status = []; foreach ($results as $result) { foreach ($result as $key => $r) { if (!array_key_exists($key, $steps)) { $steps[$key] = []; } if (!array_key_exists($r."Sum", $steps[$key])) { $steps[$key][$r."Sum"] = 0; } $steps[$key][$r."Sum"]++; $status[] = $r; } } foreach (array_unique($status) as $au) { foreach ($steps as &$step) { if (!array_key_exists($au."Sum", $step)) { $step[$au."Sum"] = 0; } } } print_r($steps);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 31
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 31
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 29
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 22
Branch analysis from position: 13
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 29
Branch analysis from position: 31
2 jumps found. (Code = 77) Position 1 = 36, Position 2 = 49
Branch analysis from position: 36
2 jumps found. (Code = 78) Position 1 = 37, Position 2 = 49
Branch analysis from position: 37
2 jumps found. (Code = 125) Position 1 = 38, Position 2 = 47
Branch analysis from position: 38
2 jumps found. (Code = 126) Position 1 = 39, Position 2 = 47
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 46
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 46
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 47
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 31
filename:       /in/8euQr
function name:  (null)
number of ops:  54
compiled vars:  !0 = $results, !1 = $steps, !2 = $status, !3 = $result, !4 = $r, !5 = $key, !6 = $au, !7 = $step
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, <array>
   22     2        ASSIGN                                                   !2, <array>
   24     3      > FE_RESET_R                                       $11     !0, ->31
          4    > > FE_FETCH_R                                               $11, !3, ->31
   25     5    > > FE_RESET_R                                       $12     !3, ->29
          6    > > FE_FETCH_R                                       ~13     $12, !4, ->29
          7    >   ASSIGN                                                   !5, ~13
   26     8        ARRAY_KEY_EXISTS                                 ~15     !5, !1
          9        BOOL_NOT                                         ~16     ~15
         10      > JMPZ                                                     ~16, ->13
   27    11    >   ASSIGN_DIM                                               !1, !5
         12        OP_DATA                                                  <array>
   29    13    >   CONCAT                                           ~18     !4, 'Sum'
         14        FETCH_DIM_R                                      ~19     !1, !5
         15        ARRAY_KEY_EXISTS                                 ~20     ~18, ~19
         16        BOOL_NOT                                         ~21     ~20
         17      > JMPZ                                                     ~21, ->22
   30    18    >   CONCAT                                           ~23     !4, 'Sum'
         19        FETCH_DIM_W                                      $22     !1, !5
         20        ASSIGN_DIM                                               $22, ~23
         21        OP_DATA                                                  0
   32    22    >   CONCAT                                           ~26     !4, 'Sum'
         23        FETCH_DIM_RW                                     $25     !1, !5
         24        FETCH_DIM_RW                                     $27     $25, ~26
         25        PRE_INC                                                  $27
   33    26        ASSIGN_DIM                                               !2
         27        OP_DATA                                                  !4
   25    28      > JMP                                                      ->6
         29    >   FE_FREE                                                  $12
   24    30      > JMP                                                      ->4
         31    >   FE_FREE                                                  $11
   37    32        INIT_FCALL                                               'array_unique'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $30     
         35      > FE_RESET_R                                       $31     $30, ->49
         36    > > FE_FETCH_R                                               $31, !6, ->49
   38    37    > > FE_RESET_RW                                      $32     !1, ->47
         38    > > FE_FETCH_RW                                              $32, !7, ->47
   39    39    >   CONCAT                                           ~33     !6, 'Sum'
         40        ARRAY_KEY_EXISTS                                 ~34     ~33, !7
         41        BOOL_NOT                                         ~35     ~34
         42      > JMPZ                                                     ~35, ->46
   40    43    >   CONCAT                                           ~36     !6, 'Sum'
         44        ASSIGN_DIM                                               !7, ~36
         45        OP_DATA                                                  0
   38    46    > > JMP                                                      ->38
         47    >   FE_FREE                                                  $32
   37    48      > JMP                                                      ->36
         49    >   FE_FREE                                                  $31
   45    50        INIT_FCALL                                               'print_r'
         51        SEND_VAR                                                 !1
         52        DO_ICALL                                                 
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.65 ms | 1016 KiB | 15 Q