3v4l.org

run code in 300+ PHP versions simultaneously
<?php $configArray = array( 'nominal' => array( 'before' => array('subtotal'), 'after' => array(), '_code' => 'nominal', ), 'subtotal' => array( 'after' => array('nominal'), 'before' => array('grand_total'), '_code' => 'subtotal', ), 'shipping' => array( 'after' => array('subtotal', 'freeshipping', 'tax_subtotal'), 'before' => array('grand_total'), '_code' => 'shipping', ), 'grand_total' => array( 'after' => array( 0 => 'subtotal', ), 'before' => array(), '_code' => 'grand_total', ), 'msrp' => array( 'before' => array(), 'after' => array(), '_code' => 'msrp', ), 'freeshipping' => array( 'after' => array( 0 => 'subtotal', ), 'before' => array( 0 => 'tax_subtotal', 1 => 'shipping', ), '_code' => 'freeshipping', ), 'discount' => array( 'after' => array( 0 => 'subtotal', 1 => 'shipping', ), 'before' => array( 0 => 'grand_total', ), '_code' => 'discount', ), 'tax_subtotal' => array( 'after' => array( 0 => 'freeshipping', ), 'before' => array( 0 => 'tax', 1 => 'discount', ), '_code' => 'tax_subtotal', ), 'tax_shipping' => array( 'after' => array( 0 => 'shipping', 1 => 'tax_subtotal', ), 'before' => array( 0 => 'tax', 1 => 'discount', ), '_code' => 'tax_shipping', ), 'tax' => array( 'after' => array( 0 => 'subtotal', 1 => 'shipping', 2 => 'discount', ), 'before' => array( 0 => 'grand_total', ), '_code' => 'tax', ), ); 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/Cotso
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>
  108     1        INIT_FCALL                                               'reset'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
  109     4        INIT_FCALL                                               'current'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
  110     8      > FE_RESET_R                                       $10     !0, ->98
          9    > > FE_FETCH_R                                       ~11     $10, !2, ->98
         10    >   ASSIGN                                                   !3, ~11
  111    11        FETCH_DIM_R                                      ~13     !2, 'before'
         12      > FE_RESET_R                                       $14     ~13, ->53
         13    > > FE_FETCH_R                                               $14, !4, ->53
  112    14    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !0, !4
         15        BOOL_NOT                                         ~16     ~15
         16      > JMPZ                                                     ~16, ->18
  113    17    > > JMP                                                      ->13
  115    18    >   INIT_FCALL                                               'array_unique'
  116    19        INIT_FCALL                                               'array_merge'
  117    20        FETCH_DIM_R                                      ~19     !0, !3
         21        FETCH_DIM_R                                      ~20     ~19, 'before'
         22        SEND_VAL                                                 ~20
  118    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     
  115    29        FETCH_DIM_W                                      $17     !0, !3
         30        ASSIGN_DIM                                               $17, 'before'
  118    31        OP_DATA                                                  $24
  121    32        INIT_FCALL                                               'array_merge'
  122    33        FETCH_DIM_R                                      ~27     !0, !4
         34        FETCH_DIM_R                                      ~28     ~27, 'after'
         35        SEND_VAL                                                 ~28
  123    36        INIT_ARRAY                                       ~29     !3
         37        SEND_VAL                                                 ~29
  124    38        FETCH_DIM_R                                      ~30     !2, 'after'
         39        SEND_VAL                                                 ~30
         40        DO_ICALL                                         $31     
  121    41        FETCH_DIM_W                                      $25     !0, !4
         42        ASSIGN_DIM                                               $25, 'after'
  124    43        OP_DATA                                                  $31
  126    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
  111    52      > JMP                                                      ->13
         53    >   FE_FREE                                                  $14
  128    54        FETCH_DIM_R                                      ~37     !2, 'after'
         55      > FE_RESET_R                                       $38     ~37, ->96
         56    > > FE_FETCH_R                                               $38, !5, ->96
  129    57    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~39     !0, !5
         58        BOOL_NOT                                         ~40     ~39
         59      > JMPZ                                                     ~40, ->61
  130    60    > > JMP                                                      ->56
  132    61    >   INIT_FCALL                                               'array_unique'
  133    62        INIT_FCALL                                               'array_merge'
  134    63        FETCH_DIM_R                                      ~43     !0, !3
         64        FETCH_DIM_R                                      ~44     ~43, 'after'
         65        SEND_VAL                                                 ~44
  135    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     
  132    72        FETCH_DIM_W                                      $41     !0, !3
         73        ASSIGN_DIM                                               $41, 'after'
  135    74        OP_DATA                                                  $48
  138    75        INIT_FCALL                                               'array_merge'
  139    76        FETCH_DIM_R                                      ~51     !0, !5
         77        FETCH_DIM_R                                      ~52     ~51, 'before'
         78        SEND_VAL                                                 ~52
  140    79        INIT_ARRAY                                       ~53     !3
         80        SEND_VAL                                                 ~53
  141    81        FETCH_DIM_R                                      ~54     !2, 'before'
         82        SEND_VAL                                                 ~54
         83        DO_ICALL                                         $55     
  138    84        FETCH_DIM_W                                      $49     !0, !5
         85        ASSIGN_DIM                                               $49, 'before'
  141    86        OP_DATA                                                  $55
  143    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
  128    95      > JMP                                                      ->56
         96    >   FE_FREE                                                  $38
  110    97      > JMP                                                      ->9
         98    >   FE_FREE                                                  $10
  146    99        INIT_FCALL                                               'uasort'
        100        SEND_REF                                                 !0
        101        SEND_VAL                                                 'compareTotals'
        102        DO_ICALL                                                 
  148   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:
160.32 ms | 1404 KiB | 25 Q