3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hasNonEmptyArray(array $array): bool { foreach ($array as $k => $v) { if (is_array($v)) { if (hasNonEmptyArray($v)) { return true; // pass deeper true outcome up the call chain } } else { echo "Found element $k\n"; return true; } } return false; } $array = [ [ 'one' => [], 'two' => [ 'a' => [ 'foo' => [], ], 'b' => [] ], 'three' => [ 'c' => [ 'fizz' => 'buzz' ] ] ] ]; var_export(hasNonEmptyArray($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/09Qjv
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   35     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'hasnonemptyarray'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function hasnonemptyarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 20
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/09Qjv
function name:  hasNonEmptyArray
number of ops:  24
compiled vars:  !0 = $array, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1      > FE_RESET_R                                       $3      !0, ->20
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->20
          3    >   ASSIGN                                                   !2, ~4
    6     4        TYPE_CHECK                                  128          !1
          5      > JMPZ                                                     ~6, ->13
    7     6    >   INIT_FCALL_BY_NAME                                       'hasNonEmptyArray'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $7      
          9      > JMPZ                                                     $7, ->12
    8    10    >   FE_FREE                                                  $3
         11      > RETURN                                                   <true>
    6    12    > > JMP                                                      ->19
   11    13    >   ROPE_INIT                                     3  ~9      'Found+element+'
         14        ROPE_ADD                                      1  ~9      ~9, !2
         15        ROPE_END                                      2  ~8      ~9, '%0A'
         16        ECHO                                                     ~8
   12    17        FE_FREE                                                  $3
         18      > RETURN                                                   <true>
    5    19    > > JMP                                                      ->2
         20    >   FE_FREE                                                  $3
   15    21      > RETURN                                                   <false>
   16    22*       VERIFY_RETURN_TYPE                                       
         23*     > RETURN                                                   null

End of function hasnonemptyarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.59 ms | 1017 KiB | 15 Q