3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rpcStructToArray(array $data, $struct) { return rpcKeyValToArray( $data['methodResponse']['params']['param']['value']['struct'][$struct] ); } function rpcKeyValToArray(array $data) { $output = []; foreach ($data as $d) { $key = $d['name']; $value = $d['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 = rpcStructToArray($data, 'member'); var_dump($member);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8QJS2
function name:  (null)
number of ops:  10
compiled vars:  !0 = $data, !1 = $member
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, <array>
   52     1        INIT_FCALL                                               'rpcstructtoarray'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'member'
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   54     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function rpcstructtoarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8QJS2
function name:  rpcStructToArray
number of ops:  14
compiled vars:  !0 = $data, !1 = $struct
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL_BY_NAME                                       'rpcKeyValToArray'
          3        CHECK_FUNC_ARG                                           
    5     4        FETCH_DIM_FUNC_ARG                               $2      !0, 'methodResponse'
          5        FETCH_DIM_FUNC_ARG                               $3      $2, 'params'
          6        FETCH_DIM_FUNC_ARG                               $4      $3, 'param'
          7        FETCH_DIM_FUNC_ARG                               $5      $4, 'value'
          8        FETCH_DIM_FUNC_ARG                               $6      $5, 'struct'
          9        FETCH_DIM_FUNC_ARG                               $7      $6, !1
         10        SEND_FUNC_ARG                                            $7
         11        DO_FCALL                                      0  $8      
         12      > RETURN                                                   $8
    7    13*     > RETURN                                                   null

End of function rpcstructtoarray

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

End of function rpckeyvaltoarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.24 ms | 1403 KiB | 18 Q