3v4l.org

run code in 300+ PHP versions simultaneously
<?php $configArray = array( 'grand_total' => array( 'before' => array(), '_code' => 'grand_total', ), 'discount' => array( 'before' => array('grand_total'), '_code' => 'discount', ), ); reset($configArray); $element = current($configArray); foreach ($configArray as $code => $data) { foreach ($data['before'] as $beforeCode) { if (!isset($configArray[$beforeCode])) { continue; } $configArray[$code]['before'] = array_unique( array_merge( $configArray[$code]['before'], $configArray[$beforeCode]['before'] ) ); $configArray[$beforeCode]['after'] = array_merge( $configArray[$beforeCode]['after'], array($code), $data['after'] ); $configArray[$beforeCode]['after'] = array_unique($configArray[$beforeCode]['after']); } } print_r($configArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 55
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 55
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 53
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 53
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 53
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
filename:       /in/5KbtG
function name:  (null)
number of ops:  60
compiled vars:  !0 = $configArray, !1 = $element, !2 = $data, !3 = $code, !4 = $beforeCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL                                               'reset'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
   14     4        INIT_FCALL                                               'current'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !1, $7
   15     8      > FE_RESET_R                                       $9      !0, ->55
          9    > > FE_FETCH_R                                       ~10     $9, !2, ->55
         10    >   ASSIGN                                                   !3, ~10
   16    11        FETCH_DIM_R                                      ~12     !2, 'before'
         12      > FE_RESET_R                                       $13     ~12, ->53
         13    > > FE_FETCH_R                                               $13, !4, ->53
   17    14    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !0, !4
         15        BOOL_NOT                                         ~15     ~14
         16      > JMPZ                                                     ~15, ->18
   18    17    > > JMP                                                      ->13
   20    18    >   INIT_FCALL                                               'array_unique'
   21    19        INIT_FCALL                                               'array_merge'
   22    20        FETCH_DIM_R                                      ~18     !0, !3
         21        FETCH_DIM_R                                      ~19     ~18, 'before'
         22        SEND_VAL                                                 ~19
   23    23        FETCH_DIM_R                                      ~20     !0, !4
         24        FETCH_DIM_R                                      ~21     ~20, 'before'
         25        SEND_VAL                                                 ~21
         26        DO_ICALL                                         $22     
         27        SEND_VAR                                                 $22
         28        DO_ICALL                                         $23     
   20    29        FETCH_DIM_W                                      $16     !0, !3
         30        ASSIGN_DIM                                               $16, 'before'
   23    31        OP_DATA                                                  $23
   26    32        INIT_FCALL                                               'array_merge'
   27    33        FETCH_DIM_R                                      ~26     !0, !4
         34        FETCH_DIM_R                                      ~27     ~26, 'after'
         35        SEND_VAL                                                 ~27
   28    36        INIT_ARRAY                                       ~28     !3
         37        SEND_VAL                                                 ~28
   29    38        FETCH_DIM_R                                      ~29     !2, 'after'
         39        SEND_VAL                                                 ~29
         40        DO_ICALL                                         $30     
   26    41        FETCH_DIM_W                                      $24     !0, !4
         42        ASSIGN_DIM                                               $24, 'after'
   29    43        OP_DATA                                                  $30
   31    44        INIT_FCALL                                               'array_unique'
         45        FETCH_DIM_R                                      ~33     !0, !4
         46        FETCH_DIM_R                                      ~34     ~33, 'after'
         47        SEND_VAL                                                 ~34
         48        DO_ICALL                                         $35     
         49        FETCH_DIM_W                                      $31     !0, !4
         50        ASSIGN_DIM                                               $31, 'after'
         51        OP_DATA                                                  $35
   16    52      > JMP                                                      ->13
         53    >   FE_FREE                                                  $13
   15    54      > JMP                                                      ->9
         55    >   FE_FREE                                                  $9
   35    56        INIT_FCALL                                               'print_r'
         57        SEND_VAR                                                 !0
         58        DO_ICALL                                                 
         59      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.68 ms | 1400 KiB | 23 Q