3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 'history' => [ 'id' => 23452435, 'legend' => [ ['player' => 'me', 'turn' => 1, 'card' => ['name' => 'foo']], ['player' => 'me', 'turn' => 1, 'card' => ['name' => 'bar']], ['player' => 'opponent', 'turn' => 1, 'card' => ['name' => 'derp']], ['player' => 'opponent', 'turn' => 2, 'card' => ['name' => 'hoo']], ], ] ]; $result = []; foreach ($data['history']['legend'] as ['player' => $p, 'turn' => $t, 'card' => ['name' => $cn]]) { if (!isset($ref[$t])) { $ref[$t] = ['me' => [], 'opponent' => []]; $result[] =& $ref[$t]; } $ref[$t][$p][] = $cn; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 29
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 24
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/cS1GiT
function name:  (null)
number of ops:  34
compiled vars:  !0 = $data, !1 = $result, !2 = $p, !3 = $t, !4 = $cn, !5 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, <array>
   16     2        FETCH_DIM_R                                      ~8      !0, 'history'
          3        FETCH_DIM_R                                      ~9      ~8, 'legend'
          4      > FE_RESET_R                                       $10     ~9, ->29
          5    > > FE_FETCH_R                                               $10, $11, ->29
          6    >   FETCH_LIST_R                                     $12     $11, 'player'
          7        ASSIGN                                                   !2, $12
          8        FETCH_LIST_R                                     $14     $11, 'turn'
          9        ASSIGN                                                   !3, $14
         10        FETCH_LIST_R                                     $16     $11, 'card'
         11        FETCH_LIST_R                                     $17     $16, 'name'
         12        ASSIGN                                                   !4, $17
         13        FREE                                                     $16
         14        FREE                                                     $11
   17    15        ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !5, !3
         16        BOOL_NOT                                         ~20     ~19
         17      > JMPZ                                                     ~20, ->24
   18    18    >   ASSIGN_DIM                                               !5, !3
         19        OP_DATA                                                  <array>
   19    20        FETCH_DIM_W                                      $23     !5, !3
         21        MAKE_REF                                         $24     $23
         22        FETCH_DIM_W                                      $22     !1
         23        ASSIGN_REF                                               $22, $24
   21    24    >   FETCH_DIM_W                                      $26     !5, !3
         25        FETCH_DIM_W                                      $27     $26, !2
         26        ASSIGN_DIM                                               $27
         27        OP_DATA                                                  !4
   16    28      > JMP                                                      ->5
         29    >   FE_FREE                                                  $10
   23    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:
151.35 ms | 1011 KiB | 14 Q