3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [ 0 => [ 0 => [1,2,3], // +1 1 => [4,5] // +1 ], 1 => [ 0 => [6,7], // +1 1 => [8,9,10] // +1 ] ]; function monkeys($array, $count) { foreach ($array as $sub) { if (! is_array($sub)) { return ++$count; } else { return ($count += monkeys($sub, $count)); } } } $count = 0; var_dump(monkeys($array,$count)); var_dump($count);
based on 7tSYF
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/KhWvR
function name:  (null)
number of ops:  14
compiled vars:  !0 = $array, !1 = $count
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   6     0  E >   ASSIGN                                                   !0, <array>
  13     1        NOP                                                      
  23     2        ASSIGN                                                   !1, 0
  24     3        INIT_FCALL                                               'var_dump'
         4        INIT_FCALL                                               'monkeys'
         5        SEND_VAR                                                 !0
         6        SEND_VAR                                                 !1
         7        DO_FCALL                                      0  $4      
         8        SEND_VAR                                                 $4
         9        DO_ICALL                                                 
  25    10        INIT_FCALL                                               'var_dump'
        11        SEND_VAR                                                 !1
        12        DO_ICALL                                                 
        13      > RETURN                                                   1

Function monkeys:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
Jump found. Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
Jump found. Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
Jump found. Position 1 = -2
Branch analysis from position: 11
Jump found. Position 1 = -2
Branch analysis from position: 19
Jump found. Position 1 = -2
Branch analysis from position: 19
filename:       /in/KhWvR
function name:  monkeys
number of ops:  21
compiled vars:  !0 = $array, !1 = $count, !2 = $sub
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  13     0  E >   RECV                                             !0      
         1        RECV                                             !1      
  14     2      > FE_RESET_R                                       $3      !0, ->19
         3    > > FE_FETCH_R                                               $3, !2, ->19
  15     4    >   TYPE_CHECK                                    7  ~4      !2
         5        BOOL_NOT                                         ~5      ~4
         6      > JMPZ                                                     ~5, ->11
  16     7    >   PRE_INC                                          $6      !1
         8        FE_FREE                                                  $3
         9      > RETURN                                                   $6
        10*       JMP                                                      ->18
  18    11    >   INIT_FCALL_BY_NAME                                       'monkeys'
        12        SEND_VAR_EX                                              !2
        13        SEND_VAR_EX                                              !1
        14        DO_FCALL                                      0  $7      
        15        ASSIGN_ADD                                    0  $8      !1, $7
        16        FE_FREE                                                  $3
        17      > RETURN                                                   $8
        18*       JMP                                                      ->3
        19    >   FE_FREE                                                  $3
  21    20      > RETURN                                                   null

End of function monkeys

Generated using Vulcan Logic Dumper, using php 7.2.0