3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'abc' => [ [ 'foo' => '*', 'action' => 'Read', 'resource' => [ 'name' => 'name_1', 'patternType' => 'fixed', 'type' => 'partition', ], ], [ 'foo' => '*', 'action' => 'Write', 'resource' => [ 'name' => 'name_1', 'patternType' => 'fixed', 'type' => 'partition', ], ], [ 'foo' => '*', 'action' => 'Read', 'resource' => [ 'name' => 'name_2', 'patternType' => 'fixed', 'type' => 'partition', ], ], [ 'foo' => '*', 'action' => 'Alter', 'resource' => [ 'name' => 'name_2', 'patternType' => 'fixed', 'type' => 'partition', ], ], ], ]; foreach ($array as $key => &$sets) { foreach ($sets as $i => &$set) { $id = $set['resource']['name']; if (!isset($ref[$id])) { $set['action'] = (array) $set['action']; $ref[$id] = &$set['action']; } else { $ref[$id][] = $set['action']; unset($array[$key][$i]); } } } var_export($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 31
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 31
Branch analysis from position: 3
2 jumps found. (Code = 125) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 126) Position 1 = 6, Position 2 = 29
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 29
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/fIWcH
function name:  (null)
number of ops:  36
compiled vars:  !0 = $array, !1 = $sets, !2 = $key, !3 = $set, !4 = $i, !5 = $id, !6 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   44     1      > FE_RESET_RW                                      $8      !0, ->31
          2    > > FE_FETCH_RW                                      ~9      $8, !1, ->31
          3    >   ASSIGN                                                   !2, ~9
   45     4      > FE_RESET_RW                                      $11     !1, ->29
          5    > > FE_FETCH_RW                                      ~12     $11, !3, ->29
          6    >   ASSIGN                                                   !4, ~12
   46     7        FETCH_DIM_R                                      ~14     !3, 'resource'
          8        FETCH_DIM_R                                      ~15     ~14, 'name'
          9        ASSIGN                                                   !5, ~15
   47    10        ISSET_ISEMPTY_DIM_OBJ                         0  ~17     !6, !5
         11        BOOL_NOT                                         ~18     ~17
         12      > JMPZ                                                     ~18, ->22
   48    13    >   FETCH_DIM_R                                      ~20     !3, 'action'
         14        CAST                                          7  ~21     ~20
         15        ASSIGN_DIM                                               !3, 'action'
         16        OP_DATA                                                  ~21
   49    17        FETCH_DIM_W                                      $23     !3, 'action'
         18        MAKE_REF                                         $24     $23
         19        FETCH_DIM_W                                      $22     !6, !5
         20        ASSIGN_REF                                               $22, $24
   47    21      > JMP                                                      ->28
   51    22    >   FETCH_DIM_R                                      ~28     !3, 'action'
         23        FETCH_DIM_W                                      $26     !6, !5
         24        ASSIGN_DIM                                               $26
         25        OP_DATA                                                  ~28
   52    26        FETCH_DIM_UNSET                                  $29     !0, !2
         27        UNSET_DIM                                                $29, !4
   45    28    > > JMP                                                      ->5
         29    >   FE_FREE                                                  $11
   44    30      > JMP                                                      ->2
         31    >   FE_FREE                                                  $8
   56    32        INIT_FCALL                                               'var_export'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.43 ms | 1015 KiB | 14 Q