3v4l.org

run code in 300+ PHP versions simultaneously
<?php $configArray = array( 'grand_total' => array( 'after' => array(), 'before' => array(), '_code' => 'grand_total', ), 'discount' => array( 'after' => 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']); } foreach ($data['after'] as $afterCode) { if (!isset($configArray[$afterCode])) { continue; } $configArray[$code]['after'] = array_unique( array_merge( $configArray[$code]['after'], $configArray[$afterCode]['after'] ) ); $configArray[$afterCode]['before'] = array_merge( $configArray[$afterCode]['before'], array($code), $data['before'] ); $configArray[$afterCode]['before'] = array_unique($configArray[$afterCode]['before']); } } uasort($configArray, 'compareTotals'); print_r($configArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 98
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 98
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
2 jumps found. (Code = 77) Position 1 = 56, Position 2 = 96
Branch analysis from position: 56
2 jumps found. (Code = 78) Position 1 = 57, Position 2 = 96
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 61
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 96
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 96
Branch analysis from position: 53
Branch analysis from position: 98
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 98
filename:       /in/nBh7h
function name:  (null)
number of ops:  107
compiled vars:  !0 = $configArray, !1 = $element, !2 = $data, !3 = $code, !4 = $beforeCode, !5 = $afterCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   15     1        INIT_FCALL                                               'reset'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
   16     4        INIT_FCALL                                               'current'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
   17     8      > FE_RESET_R                                       $10     !0, ->98
          9    > > FE_FETCH_R                                       ~11     $10, !2, ->98
         10    >   ASSIGN                                                   !3, ~11
   18    11        FETCH_DIM_R                                      ~13     !2, 'before'
         12      > FE_RESET_R                                       $14     ~13, ->53
         13    > > FE_FETCH_R                                               $14, !4, ->53
   19    14    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !0, !4
         15        BOOL_NOT                                         ~16     ~15
         16      > JMPZ                                                     ~16, ->18
   20    17    > > JMP                                                      ->13
   22    18    >   INIT_FCALL                                               'array_unique'
   23    19        INIT_FCALL                                               'array_merge'
   24    20        FETCH_DIM_R                                      ~19     !0, !3
         21        FETCH_DIM_R                                      ~20     ~19, 'before'
         22        SEND_VAL                                                 ~20
   25    23        FETCH_DIM_R                                      ~21     !0, !4
         24        FETCH_DIM_R                                      ~22     ~21, 'before'
         25        SEND_VAL                                                 ~22
         26        DO_ICALL                                         $23     
         27        SEND_VAR                                                 $23
         28        DO_ICALL                                         $24     
   22    29        FETCH_DIM_W                                      $17     !0, !3
         30        ASSIGN_DIM                                               $17, 'before'
   25    31        OP_DATA                                                  $24
   28    32        INIT_FCALL                                               'array_merge'
   29    33        FETCH_DIM_R                                      ~27     !0, !4
         34        FETCH_DIM_R                                      ~28     ~27, 'after'
         35        SEND_VAL                                                 ~28
   30    36        INIT_ARRAY                                       ~29     !3
         37        SEND_VAL                                                 ~29
   31    38        FETCH_DIM_R                                      ~30     !2, 'after'
         39        SEND_VAL                                                 ~30
         40        DO_ICALL                                         $31     
   28    41        FETCH_DIM_W                                      $25     !0, !4
         42        ASSIGN_DIM                                               $25, 'after'
   31    43        OP_DATA                                                  $31
   33    44        INIT_FCALL                                               'array_unique'
         45        FETCH_DIM_R                                      ~34     !0, !4
         46        FETCH_DIM_R                                      ~35     ~34, 'after'
         47        SEND_VAL                                                 ~35
         48        DO_ICALL                                         $36     
         49        FETCH_DIM_W                                      $32     !0, !4
         50        ASSIGN_DIM                                               $32, 'after'
         51        OP_DATA                                                  $36
   18    52      > JMP                                                      ->13
         53    >   FE_FREE                                                  $14
   35    54        FETCH_DIM_R                                      ~37     !2, 'after'
         55      > FE_RESET_R                                       $38     ~37, ->96
         56    > > FE_FETCH_R                                               $38, !5, ->96
   36    57    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~39     !0, !5
         58        BOOL_NOT                                         ~40     ~39
         59      > JMPZ                                                     ~40, ->61
   37    60    > > JMP                                                      ->56
   39    61    >   INIT_FCALL                                               'array_unique'
   40    62        INIT_FCALL                                               'array_merge'
   41    63        FETCH_DIM_R                                      ~43     !0, !3
         64        FETCH_DIM_R                                      ~44     ~43, 'after'
         65        SEND_VAL                                                 ~44
   42    66        FETCH_DIM_R                                      ~45     !0, !5
         67        FETCH_DIM_R                                      ~46     ~45, 'after'
         68        SEND_VAL                                                 ~46
         69        DO_ICALL                                         $47     
         70        SEND_VAR                                                 $47
         71        DO_ICALL                                         $48     
   39    72        FETCH_DIM_W                                      $41     !0, !3
         73        ASSIGN_DIM                                               $41, 'after'
   42    74        OP_DATA                                                  $48
   45    75        INIT_FCALL                                               'array_merge'
   46    76        FETCH_DIM_R                                      ~51     !0, !5
         77        FETCH_DIM_R                                      ~52     ~51, 'before'
         78        SEND_VAL                                                 ~52
   47    79        INIT_ARRAY                                       ~53     !3
         80        SEND_VAL                                                 ~53
   48    81        FETCH_DIM_R                                      ~54     !2, 'before'
         82        SEND_VAL                                                 ~54
         83        DO_ICALL                                         $55     
   45    84        FETCH_DIM_W                                      $49     !0, !5
         85        ASSIGN_DIM                                               $49, 'before'
   48    86        OP_DATA                                                  $55
   50    87        INIT_FCALL                                               'array_unique'
         88        FETCH_DIM_R                                      ~58     !0, !5
         89        FETCH_DIM_R                                      ~59     ~58, 'before'
         90        SEND_VAL                                                 ~59
         91        DO_ICALL                                         $60     
         92        FETCH_DIM_W                                      $56     !0, !5
         93        ASSIGN_DIM                                               $56, 'before'
         94        OP_DATA                                                  $60
   35    95      > JMP                                                      ->56
         96    >   FE_FREE                                                  $38
   17    97      > JMP                                                      ->9
         98    >   FE_FREE                                                  $10
   53    99        INIT_FCALL                                               'uasort'
        100        SEND_REF                                                 !0
        101        SEND_VAL                                                 'compareTotals'
        102        DO_ICALL                                                 
   55   103        INIT_FCALL                                               'print_r'
        104        SEND_VAR                                                 !0
        105        DO_ICALL                                                 
        106      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.43 ms | 949 KiB | 26 Q