3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rpcKeyValToAssoc(array $data) { $output = []; foreach ($member as $m) { $value = $m['value']; $output[$m['name']] = $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/iQGNQ
function name:  (null)
number of ops:  15
compiled vars:  !0 = $data, !1 = $member
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   43     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
   45    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 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/iQGNQ
function name:  rpcKeyValToAssoc
number of ops:  17
compiled vars:  !0 = $data, !1 = $output, !2 = $member, !3 = $m, !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      !2, ->14
          3    > > FE_FETCH_R                                               $6, !3, ->14
    7     4    >   FETCH_DIM_R                                      ~7      !3, 'value'
          5        ASSIGN                                                   !4, ~7
    9     6        FETCH_DIM_R                                      ~9      !3, 'name'
          7        INIT_FCALL                                               'key'
          8        SEND_VAR                                                 !4
          9        DO_ICALL                                         $11     
         10        FETCH_DIM_R                                      ~12     !4, $11
         11        ASSIGN_DIM                                               !1, ~9
         12        OP_DATA                                                  ~12
    6    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $6
   12    15      > RETURN                                                   !1
   13    16*     > RETURN                                                   null

End of function rpckeyvaltoassoc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.16 ms | 1399 KiB | 18 Q