3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cats = [ ['id' => 1, 'category_style_code' => 'GA'], ['id' => 2, 'category_style_code' => 'PA'], ['id' => 3, 'category_style_code' => 'CA'], ['id' => 4, 'category_style_code' => 'MA'] ]; $prods = [ ['id' => 1, 'default_price' => 37.50, 'category_code' => 'MA'], ['id' => 2, 'default_price' => 36.50, 'category_code' => 'GA'], ['id' => 3, 'default_price' => 38.50, 'category_code' => 'CA'], ['id' => 4, 'default_price' => 39.50, 'category_code' => 'GA'], ]; $associative_cats = array_column($cats, null, 'category_style_code'); foreach ($prods as $row) { if (isset($associative_cats[$row['category_code']])) { $associative_cats[$row['category_code']]['products'][] = $row; } } var_export(array_values($associative_cats));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/ljjfQ
function name:  (null)
number of ops:  27
compiled vars:  !0 = $cats, !1 = $prods, !2 = $associative_cats, !3 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   15     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 'category_style_code'
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !2, $6
   16     8      > FE_RESET_R                                       $8      !1, ->19
          9    > > FE_FETCH_R                                               $8, !3, ->19
   17    10    >   FETCH_DIM_R                                      ~9      !3, 'category_code'
         11        ISSET_ISEMPTY_DIM_OBJ                         0          !2, ~9
         12      > JMPZ                                                     ~10, ->18
   18    13    >   FETCH_DIM_R                                      ~11     !3, 'category_code'
         14        FETCH_DIM_W                                      $12     !2, ~11
         15        FETCH_DIM_W                                      $13     $12, 'products'
         16        ASSIGN_DIM                                               $13
         17        OP_DATA                                                  !3
   16    18    > > JMP                                                      ->9
         19    >   FE_FREE                                                  $8
   21    20        INIT_FCALL                                               'var_export'
         21        INIT_FCALL                                               'array_values'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                         $15     
         24        SEND_VAR                                                 $15
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
130.7 ms | 1401 KiB | 19 Q