3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dot($array, $prepend = '') { $results = array(); if (!$array) return $results; foreach ($array as $key => $value) { if (is_array($value)) { $results = array_merge($results, dot($value, $prepend.$key.'.')); if ($key === 'foo') print_r($results); } else { $results[$prepend.$key] = $value; } } return $results; } $array = [ 'foo' => [], 'bar' => [ 'baz' => 1 ], ]; print_r(dot($array, 'prefix'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XXlr3
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, <array>
   34     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'dot'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'prefix'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

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

End of function dot

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158 ms | 1403 KiB | 18 Q