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) { $k = $yamlComponent['cachet']['componentgroup']; $v = $yamlComponent['cachet']['componentname']; $yamlMap[$k] = isset($yamlMap[$k]) ? array_merge((array)$yamlMap[$k], [$v]) : $v; } var_export($yamlMap);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 26
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/8T81q
function name:  (null)
number of ops:  31
compiled vars:  !0 = $yaml, !1 = $yamlMap, !2 = $yamlComponent, !3 = $k, !4 = $v
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, ->26
          4    > > FE_FETCH_R                                               $8, !2, ->26
   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                                                     ~16, ->22
         13    >   INIT_FCALL                                               'array_merge'
         14        FETCH_DIM_R                                      ~17     !1, !3
         15        CAST                                          7  ~18     ~17
         16        SEND_VAL                                                 ~18
         17        INIT_ARRAY                                       ~19     !4
         18        SEND_VAL                                                 ~19
         19        DO_ICALL                                         $20     
         20        QM_ASSIGN                                        ~21     $20
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~21     !4
         23    >   ASSIGN_DIM                                               !1, !3
         24        OP_DATA                                                  ~21
   38    25      > JMP                                                      ->4
         26    >   FE_FREE                                                  $8
   44    27        INIT_FCALL                                               'var_export'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.1 ms | 1012 KiB | 15 Q