3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dot($array, $prepend = '') { $results = array(); 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 = [ 'bar' => [ 'baz' => 1 ], 'foo' => [], ]; print_r(dot($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T709v
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                   !0, <array>
   32     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'dot'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function dot:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/T709v
function name:  dot
number of ops:  32
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      > FE_RESET_R                                       $6      !0, ->29
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->29
          5    >   ASSIGN                                                   !4, ~7
    8     6        TYPE_CHECK                                  128          !3
          7      > JMPZ                                                     ~9, ->25
   10     8    >   INIT_FCALL                                               'array_merge'
          9        SEND_VAR                                                 !2
         10        INIT_FCALL_BY_NAME                                       'dot'
         11        SEND_VAR_EX                                              !3
         12        CONCAT                                           ~10     !1, !4
         13        CONCAT                                           ~11     ~10, '.'
         14        SEND_VAL_EX                                              ~11
         15        DO_FCALL                                      0  $12     
         16        SEND_VAR                                                 $12
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !2, $13
   11    19        IS_IDENTICAL                                             !4, 'foo'
         20      > JMPZ                                                     ~15, ->24
         21    >   INIT_FCALL                                               'print_r'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                                 
         24    > > JMP                                                      ->28
   17    25    >   CONCAT                                           ~17     !1, !4
         26        ASSIGN_DIM                                               !2, ~17
         27        OP_DATA                                                  !3
    6    28    > > JMP                                                      ->4
         29    >   FE_FREE                                                  $6
   21    30      > RETURN                                                   !2
   22    31*     > RETURN                                                   null

End of function dot

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.19 ms | 1394 KiB | 18 Q