3v4l.org

run code in 300+ PHP versions simultaneously
<?php $init = [ [ 'unique_codename'=>'cars', 'sorts'=>[ ['codename' => 'cars', 'name' => 'audi'], ['codename' => 'cars', 'name' => 'volvo'] ], 'category'=>'vehicle', ], [ 'unique_codename'=>'fruit', 'sorts'=>[ ['codename' => 'fruit', 'name' => 'banana'], ['codename' => 'fruit', 'name' => 'apple'], ], 'category'=>'food', ], [ 'unique_codename'=>'vegetables', 'sorts'=>[ ['codename' => 'vegetables', 'name' => 'cauliflower'], ], 'category'=>'food', ], ]; $array = [ ['codename'=>'fruit', 'name'=>'banana', 'type'=>'yellowbanana'], ['codename'=>'fruit', 'name'=>'banana', 'type'=>'brownbanana'], ['codename'=>'cars', 'name'=>'audi', 'type'=>'a2'], ['codename'=>'fruit', 'name'=>'banana', 'type'=>'greenbanana'], ['codename'=>'cars', 'name'=>'audi', 'type'=>'a6'], ['codename'=>'cars', 'name'=>'other', 'type'=>'dummytext1'], ['codename'=>'cars', 'name'=>'other', 'type'=>'dummytext2'], ]; $init = array_combine(array_column($init, 'unique_codename'), $init); foreach ($array as $k => $item) { if (isset($init[$item['codename']])) { foreach ($init[$item['codename']]['sorts'] as &$sort) { if ($sort['name'] == $item['name']) { $sort['types'][] = $item['type']; } } } } print_r(array_values($init));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 33
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 33
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 32
Branch analysis from position: 17
2 jumps found. (Code = 125) Position 1 = 21, Position 2 = 31
Branch analysis from position: 21
2 jumps found. (Code = 126) Position 1 = 22, Position 2 = 31
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 30
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 31
Branch analysis from position: 32
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/aOARt
function name:  (null)
number of ops:  41
compiled vars:  !0 = $init, !1 = $array, !2 = $item, !3 = $k, !4 = $sort
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   29     1        ASSIGN                                                   !1, <array>
   39     2        INIT_FCALL                                               'array_combine'
          3        INIT_FCALL                                               'array_column'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'unique_codename'
          6        DO_ICALL                                         $7      
          7        SEND_VAR                                                 $7
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !0, $8
   40    11      > FE_RESET_R                                       $10     !1, ->33
         12    > > FE_FETCH_R                                       ~11     $10, !2, ->33
         13    >   ASSIGN                                                   !3, ~11
   41    14        FETCH_DIM_R                                      ~13     !2, 'codename'
         15        ISSET_ISEMPTY_DIM_OBJ                         0          !0, ~13
         16      > JMPZ                                                     ~14, ->32
   42    17    >   FETCH_DIM_R                                      ~15     !2, 'codename'
         18        FETCH_DIM_W                                      $16     !0, ~15
         19        FETCH_DIM_W                                      $17     $16, 'sorts'
         20      > FE_RESET_RW                                      $18     $17, ->31
         21    > > FE_FETCH_RW                                              $18, !4, ->31
   43    22    >   FETCH_DIM_R                                      ~19     !4, 'name'
         23        FETCH_DIM_R                                      ~20     !2, 'name'
         24        IS_EQUAL                                                 ~19, ~20
         25      > JMPZ                                                     ~21, ->30
   44    26    >   FETCH_DIM_R                                      ~24     !2, 'type'
         27        FETCH_DIM_W                                      $22     !4, 'types'
         28        ASSIGN_DIM                                               $22
         29        OP_DATA                                                  ~24
   42    30    > > JMP                                                      ->21
         31    >   FE_FREE                                                  $18
   40    32    > > JMP                                                      ->12
         33    >   FE_FREE                                                  $10
   49    34        INIT_FCALL                                               'print_r'
         35        INIT_FCALL                                               'array_values'
         36        SEND_VAR                                                 !0
         37        DO_ICALL                                         $25     
         38        SEND_VAR                                                 $25
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
277.22 ms | 1018 KiB | 17 Q