3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 'relation' => 'AND', [ 'taxonomy' => 'merk', 'field' => 'slug', 'terms' => ['coral'] ], [ 'taxonomy' => 'foo', 'field' => 'bar', 'terms' => ['stackoverflow'] ], [ 'taxonomy' => 'merk', 'field' => 'slug', 'terms' => ['deluxe', 'ultra'] ] ]; foreach ($array as $key => &$item) { if (is_array($item) && isset($item['taxonomy'], $item['field'])) { $id = $item['taxonomy'] . '_' . $item['field']; if (!isset($ref[$id])) { $ref[$id] = &$item['terms']; } else { array_push($ref[$id], ...$item['terms']); unset($array[$key]); } } } var_export($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 34
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 34
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 33
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 33
Branch analysis from position: 10
Branch analysis from position: 11
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/GtY49
function name:  (null)
number of ops:  39
compiled vars:  !0 = $array, !1 = $item, !2 = $key, !3 = $id, !4 = $ref
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   22     1      > FE_RESET_RW                                          $6      !0, ->34
          2    > > FE_FETCH_RW                                          ~7      $6, !1, ->34
          3    >   ASSIGN                                                       !2, ~7
   23     4        TYPE_CHECK                                      128  ~9      !1
          5      > JMPZ_EX                                              ~9      ~9, ->11
          6    >   ISSET_ISEMPTY_DIM_OBJ                             0  ~10     !1, 'taxonomy'
          7      > JMPZ_EX                                              ~10     ~10, ->10
          8    >   ISSET_ISEMPTY_DIM_OBJ                             0  ~11     !1, 'field'
          9        BOOL                                                 ~10     ~11
         10    >   BOOL                                                 ~9      ~10
         11    > > JMPZ                                                         ~9, ->33
   24    12    >   FETCH_DIM_R                                          ~12     !1, 'taxonomy'
         13        CONCAT                                               ~13     ~12, '_'
         14        FETCH_DIM_R                                          ~14     !1, 'field'
         15        CONCAT                                               ~15     ~13, ~14
         16        ASSIGN                                                       !3, ~15
   25    17        ISSET_ISEMPTY_DIM_OBJ                             0  ~17     !4, !3
         18        BOOL_NOT                                             ~18     ~17
         19      > JMPZ                                                         ~18, ->25
   26    20    >   FETCH_DIM_W                                          $20     !1, 'terms'
         21        MAKE_REF                                             $21     $20
         22        FETCH_DIM_W                                          $19     !4, !3
         23        ASSIGN_REF                                                   $19, $21
   25    24      > JMP                                                          ->33
   28    25    >   INIT_FCALL                                                   'array_push'
         26        FETCH_DIM_W                                          $23     !4, !3
         27        SEND_REF                                                     $23
         28        FETCH_DIM_R                                          ~24     !1, 'terms'
         29        SEND_UNPACK                                                  ~24
         30        CHECK_UNDEF_ARGS                                             
         31        DO_ICALL                                                     
   29    32        UNSET_DIM                                                    !0, !2
   22    33    > > JMP                                                          ->2
         34    >   FE_FREE                                                      $6
   33    35        INIT_FCALL                                                   'var_export'
         36        SEND_VAR                                                     !0
         37        DO_ICALL                                                     
         38      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.14 ms | 1766 KiB | 15 Q