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 $list) { $result[$list['turn']-1][$list['player']][] = $list['card']['name']; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/8XfVQ
function name:  (null)
number of ops:  21
compiled vars:  !0 = $data, !1 = $result, !2 = $list
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                                      ~5      !0, 'history'
          3        FETCH_DIM_R                                      ~6      ~5, 'legend'
          4      > FE_RESET_R                                       $7      ~6, ->16
          5    > > FE_FETCH_R                                               $7, !2, ->16
   17     6    >   FETCH_DIM_R                                      ~8      !2, 'turn'
          7        SUB                                              ~9      ~8, 1
          8        FETCH_DIM_R                                      ~11     !2, 'player'
          9        FETCH_DIM_R                                      ~14     !2, 'card'
         10        FETCH_DIM_R                                      ~15     ~14, 'name'
         11        FETCH_DIM_W                                      $10     !1, ~9
         12        FETCH_DIM_W                                      $12     $10, ~11
         13        ASSIGN_DIM                                               $12
         14        OP_DATA                                                  ~15
   16    15      > JMP                                                      ->5
         16    >   FE_FREE                                                  $7
   19    17        INIT_FCALL                                               'var_export'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.93 ms | 1009 KiB | 14 Q