3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['id'=> 1,'name'=>'イワーク','place'=>'渓谷,洞窟','level' => 10,'technique'=>'岩雪崩'], ['id'=> 1,'name'=>'イワーク','place'=>'砂漠,山頂','level' => 20,'technique'=>'岩石砲'], ['id'=> 2,'name'=>'ハガネール','place'=>'鉱山,地中','level' => 10,'technique'=>'メテオドライブ'], ['id'=> 2,'name'=>'ハガネール','place'=>'丘陵,窪地','level' => 20,'technique'=>'アイアンローラー'], ]; $places = array_reduce($data, function ($carry, $item) { ['id' => $id, 'level' => $level, 'technique' => $technique] = $item; array_push($carry[$id]['place_list'], ...explode(',', $item['place'])); $carry[$id]['lv_list'][$level] = compact('level', 'technique'); return $carry; }, array_map(fn($a) => ['id' => $a['id'], 'name' => $a['name'], 'place_list' => [], 'lv_list' => []], array_column($data, null, 'id'))); var_dump($places);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gPFQF
function name:  (null)
number of ops:  22
compiled vars:  !0 = $data, !1 = $places
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   15     4        SEND_VAL                                                 ~3
          5        INIT_FCALL                                               'array_map'
          6        DECLARE_LAMBDA_FUNCTION                          ~4      [1]
          7        SEND_VAL                                                 ~4
   16     8        INIT_FCALL                                               'array_column'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 null
         11        SEND_VAL                                                 'id'
         12        DO_ICALL                                         $5      
         13        SEND_VAR                                                 $5
   15    14        DO_ICALL                                         $6      
   16    15        SEND_VAR                                                 $6
    9    16        DO_ICALL                                         $7      
         17        ASSIGN                                                   !1, $7
   18    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
         21      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gPFQF
function name:  {closure}
number of ops:  32
compiled vars:  !0 = $carry, !1 = $item, !2 = $id, !3 = $level, !4 = $technique
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        QM_ASSIGN                                        ~5      !1
          3        FETCH_LIST_R                                     $6      ~5, 'id'
          4        ASSIGN                                                   !2, $6
          5        FETCH_LIST_R                                     $8      ~5, 'level'
          6        ASSIGN                                                   !3, $8
          7        FETCH_LIST_R                                     $10     ~5, 'technique'
          8        ASSIGN                                                   !4, $10
          9        FREE                                                     ~5
   11    10        INIT_FCALL                                               'array_push'
         11        FETCH_DIM_W                                      $12     !0, !2
         12        FETCH_DIM_W                                      $13     $12, 'place_list'
         13        SEND_REF                                                 $13
         14        INIT_FCALL                                               'explode'
         15        SEND_VAL                                                 '%2C'
         16        FETCH_DIM_R                                      ~14     !1, 'place'
         17        SEND_VAL                                                 ~14
         18        DO_ICALL                                         $15     
         19        SEND_UNPACK                                              $15
         20        CHECK_UNDEF_ARGS                                         
         21        DO_ICALL                                                 
   12    22        INIT_FCALL                                               'compact'
         23        SEND_VAL                                                 'level'
         24        SEND_VAL                                                 'technique'
         25        DO_ICALL                                         $20     
         26        FETCH_DIM_W                                      $17     !0, !2
         27        FETCH_DIM_W                                      $18     $17, 'lv_list'
         28        ASSIGN_DIM                                               $18, !3
         29        OP_DATA                                                  $20
   14    30      > RETURN                                                   !0
   15    31*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gPFQF
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'id'
          2        INIT_ARRAY                                       ~2      ~1, 'id'
          3        FETCH_DIM_R                                      ~3      !0, 'name'
          4        ADD_ARRAY_ELEMENT                                ~2      ~3, 'name'
          5        ADD_ARRAY_ELEMENT                                ~2      <array>, 'place_list'
          6        ADD_ARRAY_ELEMENT                                ~2      <array>, 'lv_list'
          7      > RETURN                                                   ~2
          8*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.46 ms | 1013 KiB | 20 Q