3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rpcKeyValToAssoc(array $data) { $output = []; foreach ($data as $d) { $key = $d['name']; $value = $d['value']; var_dump($key);var_dump($value); $output[$key] = $value[key($value)]; } return $output; } $data = [ 'methodResponse' => [ 'params' => [ 'param' => [ 'value' => [ 'struct' => [ 'member' => [ [ 'name' => 'member_id', 'value' => [ 'string' => 4958 ] ], [ 'name' => 'name', 'value' => [ 'string' => 'Username', ] ] ] ] ] ] ] ] ]; $member = rpcKeyValToAssoc($data['methodResponse']['params']['param']['value']['struct']['member']); var_dump($member);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kDL7j
function name:  (null)
number of ops:  15
compiled vars:  !0 = $data, !1 = $member
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   48     1        INIT_FCALL                                               'rpckeyvaltoassoc'
          2        FETCH_DIM_R                                      ~3      !0, 'methodResponse'
          3        FETCH_DIM_R                                      ~4      ~3, 'params'
          4        FETCH_DIM_R                                      ~5      ~4, 'param'
          5        FETCH_DIM_R                                      ~6      ~5, 'value'
          6        FETCH_DIM_R                                      ~7      ~6, 'struct'
          7        FETCH_DIM_R                                      ~8      ~7, 'member'
          8        SEND_VAL                                                 ~8
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                                   !1, $9
   50    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function rpckeyvaltoassoc:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/kDL7j
function name:  rpcKeyValToAssoc
number of ops:  24
compiled vars:  !0 = $data, !1 = $output, !2 = $d, !3 = $key, !4 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    6     2      > FE_RESET_R                                       $6      !0, ->21
          3    > > FE_FETCH_R                                               $6, !2, ->21
    7     4    >   FETCH_DIM_R                                      ~7      !2, 'name'
          5        ASSIGN                                                   !3, ~7
    8     6        FETCH_DIM_R                                      ~9      !2, 'value'
          7        ASSIGN                                                   !4, ~9
   10     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                                 
         11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                                 
   12    14        INIT_FCALL                                               'key'
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $14     
         17        FETCH_DIM_R                                      ~15     !4, $14
         18        ASSIGN_DIM                                               !1, !3
         19        OP_DATA                                                  ~15
    6    20      > JMP                                                      ->3
         21    >   FE_FREE                                                  $6
   15    22      > RETURN                                                   !1
   16    23*     > RETURN                                                   null

End of function rpckeyvaltoassoc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.72 ms | 1403 KiB | 18 Q