3v4l.org

run code in 300+ PHP versions simultaneously
<?php $categories = array( 'category_1' => array( 'name' => 'Category 1', 'column' => '1' ), 'category_2' => array( 'name' => 'Category 2', 'column' => '2' ), 'category_3' => array( 'name' => 'Category 2', 'column' => '1' ), 'category_4' => array( 'name' => 'Category 4', 'column' => '3' ), 'category_4' => array( 'name' => 'Category 4', 'column' => '2' ), ); $output = array(); foreach($categories as $catName => $category) { $columnNum = $category['column']; $key = 'column_' . $columnNum; if (!isset($output[$key] )) { $output[$key] = array($catName); } else { $output[$key][] = $catName; } } var_dump($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/kHZY5
function name:  (null)
number of ops:  25
compiled vars:  !0 = $categories, !1 = $output, !2 = $category, !3 = $catName, !4 = $columnNum, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   25     1        ASSIGN                                                   !1, <array>
   27     2      > FE_RESET_R                                       $8      !0, ->20
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->20
          4    >   ASSIGN                                                   !3, ~9
   28     5        FETCH_DIM_R                                      ~11     !2, 'column'
          6        ASSIGN                                                   !4, ~11
   29     7        CONCAT                                           ~13     'column_', !4
          8        ASSIGN                                                   !5, ~13
   31     9        ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !1, !5
         10        BOOL_NOT                                         ~16     ~15
         11      > JMPZ                                                     ~16, ->16
   32    12    >   INIT_ARRAY                                       ~18     !3
         13        ASSIGN_DIM                                               !1, !5
         14        OP_DATA                                                  ~18
         15      > JMP                                                      ->19
   34    16    >   FETCH_DIM_W                                      $19     !1, !5
         17        ASSIGN_DIM                                               $19
         18        OP_DATA                                                  !3
   27    19    > > JMP                                                      ->3
         20    >   FE_FREE                                                  $8
   38    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.53 ms | 1388 KiB | 15 Q