3v4l.org

run code in 500+ PHP versions simultaneously
<?php $items = array( array("itemName" => "Hat", "price" => 10.99, "categories" => ["apparel", "head"]), array("itemName" => "Scarf", "price" => 7.99, "categories" => ["apparel", "neck"]), array("itemName" => "Watch", "price" => 19.99, "categories" => ["jewelry", "electronics"]), array("itemName" => "Necklace", "price" => 99.99, "categories" => ["jewelry", "neck"]), array("itemName" => "Headphones", "price" => 29.99, "categories" => ["head", "electronics"]) ); foreach (array_unique(array_merge(...array_values(array_column($items, 'categories')))) as $value) { foreach ($items as $item) { if (in_array($value, $item['categories'])) { $categories[$value][] = $item['itemName']; } } } print_r($categories);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 29
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 26
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 27
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/Qag3c
function name:  (null)
number of ops:  34
compiled vars:  !0 = $items, !1 = $value, !2 = $item, !3 = $categories
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   11     1        INIT_FCALL                                                   'array_unique'
          2        INIT_FCALL                                                   'array_merge'
          3        INIT_FCALL                                                   'array_values'
          4        INIT_FCALL                                                   'array_column'
          5        SEND_VAR                                                     !0
          6        SEND_VAL                                                     'categories'
          7        DO_ICALL                                             $5      
          8        SEND_VAR                                                     $5
          9        DO_ICALL                                             $6      
         10        SEND_UNPACK                                                  $6
         11        CHECK_UNDEF_ARGS                                             
         12        DO_ICALL                                             $7      
         13        SEND_VAR                                                     $7
         14        DO_ICALL                                             $8      
         15      > FE_RESET_R                                           $9      $8, ->29
         16    > > FE_FETCH_R                                                   $9, !1, ->29
   12    17    > > FE_RESET_R                                           $10     !0, ->27
         18    > > FE_FETCH_R                                                   $10, !2, ->27
   13    19    >   FETCH_DIM_R                                          ~11     !2, 'categories'
         20        FRAMELESS_ICALL_2                in_array            ~12     !1, ~11
         21      > JMPZ                                                         ~12, ->26
   14    22    >   FETCH_DIM_R                                          ~15     !2, 'itemName'
         23        FETCH_DIM_W                                          $13     !3, !1
         24        ASSIGN_DIM                                                   $13
         25        OP_DATA                                                      ~15
   12    26    > > JMP                                                          ->18
         27    >   FE_FREE                                                      $10
   11    28      > JMP                                                          ->16
         29    >   FE_FREE                                                      $9
   19    30        INIT_FCALL                                                   'print_r'
         31        SEND_VAR                                                     !3
         32        DO_ICALL                                                     
         33      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.63 ms | 1998 KiB | 18 Q