3v4l.org

run code in 300+ PHP versions simultaneously
<?php function transfer( $arr, $prefix=array(), $glue="_" ) { $res = array(); foreach( $arr as $key => $val ) { $key = array_merge( $prefix, array($key) ); if( is_array($val) ) $res = array_merge( $res, transfer( $val, $key, $glue ) ); else $res[ implode($glue, $key) ] = $val; } return $res; } $attributes = array( 'Users' => array( 'Name' => 'Name', ), 'Address' => 'Address', 'Tags' => array( 0 => array( 'Key' => 'Key', 'Value' => 'Value', ), 1 => array( 'Key' => 'Key', ), 2 => array( ) ), ); var_dump( transfer( $attributes ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mdWQX
function name:  (null)
number of ops:  8
compiled vars:  !0 = $attributes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   30     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'transfer'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function transfer:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 33
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 33
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 26
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/mdWQX
function name:  transfer
number of ops:  36
compiled vars:  !0 = $arr, !1 = $prefix, !2 = $glue, !3 = $res, !4 = $val, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2        RECV_INIT                                        !2      '_'
    3     3        ASSIGN                                                   !3, <array>
    4     4      > FE_RESET_R                                       $7      !0, ->33
          5    > > FE_FETCH_R                                       ~8      $7, !4, ->33
          6    >   ASSIGN                                                   !5, ~8
    5     7        INIT_FCALL                                               'array_merge'
          8        SEND_VAR                                                 !1
          9        INIT_ARRAY                                       ~10     !5
         10        SEND_VAL                                                 ~10
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !5, $11
    6    13        TYPE_CHECK                                  128          !4
         14      > JMPZ                                                     ~13, ->26
         15    >   INIT_FCALL                                               'array_merge'
         16        SEND_VAR                                                 !3
         17        INIT_FCALL_BY_NAME                                       'transfer'
         18        SEND_VAR_EX                                              !4
         19        SEND_VAR_EX                                              !5
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0  $14     
         22        SEND_VAR                                                 $14
         23        DO_ICALL                                         $15     
         24        ASSIGN                                                   !3, $15
         25      > JMP                                                      ->32
    7    26    >   INIT_FCALL                                               'implode'
         27        SEND_VAR                                                 !2
         28        SEND_VAR                                                 !5
         29        DO_ICALL                                         $17     
         30        ASSIGN_DIM                                               !3, $17
         31        OP_DATA                                                  !4
    4    32    > > JMP                                                      ->5
         33    >   FE_FREE                                                  $7
    9    34      > RETURN                                                   !3
   10    35*     > RETURN                                                   null

End of function transfer

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.82 ms | 1407 KiB | 20 Q