3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array['page']['article']['header'] = "Header"; $array['page']['article']['body'] = "Body"; $array['page']['article']['footer'] = "Footer"; $array['page']['news']['header'] = "Header"; $array['page']['news']['body'] = "Body"; $array['page']['news']['footer'] = "Footer"; function rearrange($array){ $output = []; foreach($array as $key => $val){ if(is_array($val)){ $out = rearrange($val); foreach($out as $sub_key => $sub_val){ $output[$key . "." . $sub_key] = $sub_val; } }else{ $output[$key] = $val; } } return $output; } print_r(rearrange($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40hjK
function name:  (null)
number of ops:  31
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   FETCH_DIM_W                                          $1      !0, 'page'
          1        FETCH_DIM_W                                          $2      $1, 'article'
          2        ASSIGN_DIM                                                   $2, 'header'
          3        OP_DATA                                                      'Header'
    4     4        FETCH_DIM_W                                          $4      !0, 'page'
          5        FETCH_DIM_W                                          $5      $4, 'article'
          6        ASSIGN_DIM                                                   $5, 'body'
          7        OP_DATA                                                      'Body'
    5     8        FETCH_DIM_W                                          $7      !0, 'page'
          9        FETCH_DIM_W                                          $8      $7, 'article'
         10        ASSIGN_DIM                                                   $8, 'footer'
         11        OP_DATA                                                      'Footer'
    6    12        FETCH_DIM_W                                          $10     !0, 'page'
         13        FETCH_DIM_W                                          $11     $10, 'news'
         14        ASSIGN_DIM                                                   $11, 'header'
         15        OP_DATA                                                      'Header'
    7    16        FETCH_DIM_W                                          $13     !0, 'page'
         17        FETCH_DIM_W                                          $14     $13, 'news'
         18        ASSIGN_DIM                                                   $14, 'body'
         19        OP_DATA                                                      'Body'
    8    20        FETCH_DIM_W                                          $16     !0, 'page'
         21        FETCH_DIM_W                                          $17     $16, 'news'
         22        ASSIGN_DIM                                                   $17, 'footer'
         23        OP_DATA                                                      'Footer'
   26    24        INIT_FCALL                                                   'print_r'
         25        INIT_FCALL                                                   'rearrange'
         26        SEND_VAR                                                     !0
         27        DO_FCALL                                          0  $19     
         28        SEND_VAR                                                     $19
         29        DO_ICALL                                                     
         30      > RETURN                                                       1

Function rearrange:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/40hjK
function name:  rearrange
number of ops:  27
compiled vars:  !0 = $array, !1 = $output, !2 = $val, !3 = $key, !4 = $out, !5 = $sub_val, !6 = $sub_key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   11     1        ASSIGN                                                       !1, <array>
   12     2      > FE_RESET_R                                           $8      !0, ->24
          3    > > FE_FETCH_R                                           ~9      $8, !2, ->24
          4    >   ASSIGN                                                       !3, ~9
   13     5        TYPE_CHECK                                      128          !2
          6      > JMPZ                                                         ~11, ->21
   14     7    >   INIT_FCALL_BY_NAME                                           'rearrange'
          8        SEND_VAR_EX                                                  !2
          9        DO_FCALL                                          0  $12     
         10        ASSIGN                                                       !4, $12
   15    11      > FE_RESET_R                                           $14     !4, ->19
         12    > > FE_FETCH_R                                           ~15     $14, !5, ->19
         13    >   ASSIGN                                                       !6, ~15
   16    14        CONCAT                                               ~17     !3, '.'
         15        CONCAT                                               ~18     ~17, !6
         16        ASSIGN_DIM                                                   !1, ~18
         17        OP_DATA                                                      !5
   15    18      > JMP                                                          ->12
         19    >   FE_FREE                                                      $14
   13    20      > JMP                                                          ->23
   19    21    >   ASSIGN_DIM                                                   !1, !3
         22        OP_DATA                                                      !2
   12    23    > > JMP                                                          ->3
         24    >   FE_FREE                                                      $8
   23    25      > RETURN                                                       !1
   24    26*     > RETURN                                                       null

End of function rearrange

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.33 ms | 2154 KiB | 15 Q