3v4l.org

run code in 300+ PHP versions simultaneously
<?php $yaml = [ 'components' => [ [ 'cachet' => [ 'componentgroup' => 'FOO', 'componentname' => 'BAR' ] ], [ 'cachet' => [ 'componentgroup' => 'Key1', 'componentname' => 'Value1' ] ], [ 'cachet' => [ 'componentgroup' => 'Key2', 'componentname' => 'Value2' ] ], [ 'cachet' => [ 'componentgroup' => 'FOO', 'componentname' => 'BAZ' ] ], [ 'cachet' => [ 'componentgroup' => 'Key3', 'componentname' => 'Value3' ] ] ] ]; $yamlMap = []; foreach ($yaml['components'] as $yamlComponent) { $key = $yamlComponent['cachet']['componentgroup']; $value = $yamlComponent['cachet']['componentname']; if (isset($yamlMap[$key])) { if (is_array($yamlMap[$key])) { $yamlMap[$key][] = $value; } else { $yamlMap[$key] = [$yamlMap[$key], $value]; } } else { $yamlMap[$key] = $value; } } var_export($yamlMap);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/vBDPU
function name:  (null)
number of ops:  34
compiled vars:  !0 = $yaml, !1 = $yamlMap, !2 = $yamlComponent, !3 = $key, !4 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   37     1        ASSIGN                                                   !1, <array>
   38     2        FETCH_DIM_R                                      ~7      !0, 'components'
          3      > FE_RESET_R                                       $8      ~7, ->29
          4    > > FE_FETCH_R                                               $8, !2, ->29
   39     5    >   FETCH_DIM_R                                      ~9      !2, 'cachet'
          6        FETCH_DIM_R                                      ~10     ~9, 'componentgroup'
          7        ASSIGN                                                   !3, ~10
   40     8        FETCH_DIM_R                                      ~12     !2, 'cachet'
          9        FETCH_DIM_R                                      ~13     ~12, 'componentname'
         10        ASSIGN                                                   !4, ~13
   41    11        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !3
         12      > JMPZ                                                     ~15, ->26
   42    13    >   FETCH_DIM_R                                      ~16     !1, !3
         14        TYPE_CHECK                                  128          ~16
         15      > JMPZ                                                     ~17, ->20
   43    16    >   FETCH_DIM_W                                      $18     !1, !3
         17        ASSIGN_DIM                                               $18
         18        OP_DATA                                                  !4
   42    19      > JMP                                                      ->25
   45    20    >   FETCH_DIM_R                                      ~21     !1, !3
         21        INIT_ARRAY                                       ~22     ~21
         22        ADD_ARRAY_ELEMENT                                ~22     !4
         23        ASSIGN_DIM                                               !1, !3
         24        OP_DATA                                                  ~22
   41    25    > > JMP                                                      ->28
   48    26    >   ASSIGN_DIM                                               !1, !3
         27        OP_DATA                                                  !4
   38    28    > > JMP                                                      ->4
         29    >   FE_FREE                                                  $8
   52    30        INIT_FCALL                                               'var_export'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.39 ms | 1015 KiB | 14 Q