3v4l.org

run code in 300+ PHP versions simultaneously
<?php $method_filters = [ 'exists' => [ 'full pallet' => [ 171 => [ 'pakkelabels_shipping_gls_private', 'pakkelabels_shipping_postnord_private', 'pakkelabels_shipping_gls', 'pakkelabels_shipping_pdk', 'flat_rate:15', 'flat_rate:14' ], ], 'half pallet' => [ 169 => [ 'pakkelabels_shipping_gls_private', 'pakkelabels_shipping_postnord_private', 'pakkelabels_shipping_gls', 'pakkelabels_shipping_pdk', 'flat_rate:15' ], ], 'quarter pallet' => [ 211 => [ 'pakkelabels_shipping_gls_private', 'pakkelabels_shipping_postnord_private', 'pakkelabels_shipping_gls', 'pakkelabels_shipping_pdk' ], ] ], 'not exists' => [ 'full pallet' => [ 171 => [ 'flat_rate:12' ] ], 'half pallet' => [ 169 => [ 'flat_rate:14' ] ], 'quarter pallet' => [ 211 => [ 'flat_rate:15' ] ] ] ]; $class_ids[170] = ''; $class_ids[171] = ''; $available_shipping_methods['flat_rate:12'] = 'something'; $available_shipping_methods['flat_rate:14'] = 'somethingelse'; foreach ($method_filters as $filter_type => $pallet_filters) { // iterate exists/not exists level foreach ($pallet_filters as $pallet_type => $shipping_methods) { // iterate different pallets level if ($filter_type == 'exists') { $qualifiers = array_intersect_key($shipping_methods, $class_ids); } else { $qualifiers = array_diff_key($shipping_methods, $class_ids); } foreach ($qualifiers as $class_id => $method_names) { // only iterate if there are qualifying class ids foreach ($method_names as $method_name) { echo "unsetting $method_name\n"; unset($available_shipping_methods[$method_name]); } } } } var_export($available_shipping_methods);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 45
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 45
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 43
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 43
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 41
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 41
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 39
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 39
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 39
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 41
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 41
Branch analysis from position: 29
Branch analysis from position: 41
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 43
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
filename:       /in/r4WPg
function name:  (null)
number of ops:  50
compiled vars:  !0 = $method_filters, !1 = $class_ids, !2 = $available_shipping_methods, !3 = $pallet_filters, !4 = $filter_type, !5 = $shipping_methods, !6 = $pallet_type, !7 = $qualifiers, !8 = $method_names, !9 = $class_id, !10 = $method_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   52     1        ASSIGN_DIM                                               !1, 170
          2        OP_DATA                                                  ''
   53     3        ASSIGN_DIM                                               !1, 171
          4        OP_DATA                                                  ''
   55     5        ASSIGN_DIM                                               !2, 'flat_rate%3A12'
          6        OP_DATA                                                  'something'
   56     7        ASSIGN_DIM                                               !2, 'flat_rate%3A14'
          8        OP_DATA                                                  'somethingelse'
   58     9      > FE_RESET_R                                       $16     !0, ->45
         10    > > FE_FETCH_R                                       ~17     $16, !3, ->45
         11    >   ASSIGN                                                   !4, ~17
   59    12      > FE_RESET_R                                       $19     !3, ->43
         13    > > FE_FETCH_R                                       ~20     $19, !5, ->43
         14    >   ASSIGN                                                   !6, ~20
   60    15        IS_EQUAL                                                 !4, 'exists'
         16      > JMPZ                                                     ~22, ->23
   61    17    >   INIT_FCALL                                               'array_intersect_key'
         18        SEND_VAR                                                 !5
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $23     
         21        ASSIGN                                                   !7, $23
         22      > JMP                                                      ->28
   63    23    >   INIT_FCALL                                               'array_diff_key'
         24        SEND_VAR                                                 !5
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $25     
         27        ASSIGN                                                   !7, $25
   65    28    > > FE_RESET_R                                       $27     !7, ->41
         29    > > FE_FETCH_R                                       ~28     $27, !8, ->41
         30    >   ASSIGN                                                   !9, ~28
   66    31      > FE_RESET_R                                       $30     !8, ->39
         32    > > FE_FETCH_R                                               $30, !10, ->39
   67    33    >   ROPE_INIT                                     3  ~32     'unsetting+'
         34        ROPE_ADD                                      1  ~32     ~32, !10
         35        ROPE_END                                      2  ~31     ~32, '%0A'
         36        ECHO                                                     ~31
   68    37        UNSET_DIM                                                !2, !10
   66    38      > JMP                                                      ->32
         39    >   FE_FREE                                                  $30
   65    40      > JMP                                                      ->29
         41    >   FE_FREE                                                  $27
   59    42      > JMP                                                      ->13
         43    >   FE_FREE                                                  $19
   58    44      > JMP                                                      ->10
         45    >   FE_FREE                                                  $16
   74    46        INIT_FCALL                                               'var_export'
         47        SEND_VAR                                                 !2
         48        DO_ICALL                                                 
         49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
301.44 ms | 1400 KiB | 20 Q