3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [10, [[[]],[]], 'hello', [1, 2, 3, ['hi', 7]], [15, 67], 12]; function array_tally_recursive(array $array): int { $tally = 0; foreach ($array as $item) { if (is_array($item)) { $tally += 1 + array_tally_recursive($item); } } return $tally; } echo array_tally_recursive($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L3JmP
function name:  (null)
number of ops:  6
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   16     1        INIT_FCALL                                               'array_tally_recursive'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function array_tally_recursive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/L3JmP
function name:  array_tally_recursive
number of ops:  17
compiled vars:  !0 = $array, !1 = $tally, !2 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, 0
    8     2      > FE_RESET_R                                       $4      !0, ->12
          3    > > FE_FETCH_R                                               $4, !2, ->12
    9     4    >   TYPE_CHECK                                  128          !2
          5      > JMPZ                                                     ~5, ->11
   10     6    >   INIT_FCALL_BY_NAME                                       'array_tally_recursive'
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0  $6      
          9        ADD                                              ~7      1, $6
         10        ASSIGN_OP                                     1          !1, ~7
    8    11    > > JMP                                                      ->3
         12    >   FE_FREE                                                  $4
   13    13        VERIFY_RETURN_TYPE                                       !1
         14      > RETURN                                                   !1
   14    15*       VERIFY_RETURN_TYPE                                       
         16*     > RETURN                                                   null

End of function array_tally_recursive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.82 ms | 1012 KiB | 14 Q