3v4l.org

run code in 300+ PHP versions simultaneously
<?php $parents = [1 => 0, 2 => 1, 3 => 2]; $cache = [1 => 5, 2 => 4, 3 => 3]; function count_posts($category_id, $parents, $cache) { $sum = 0; foreach ($parents as $child) { $sum += count_posts($child, $parents, $child); } $sum += $cache[$category_id]; return $sum; } count_posts(1, $parents, $cache);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QHqBH
function name:  (null)
number of ops:  8
compiled vars:  !0 = $parents, !1 = $cache
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
   15     2        INIT_FCALL                                               'count_posts'
          3        SEND_VAL                                                 1
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function count_posts:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/QHqBH
function name:  count_posts
number of ops:  18
compiled vars:  !0 = $category_id, !1 = $parents, !2 = $cache, !3 = $sum, !4 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        ASSIGN                                                   !3, 0
    8     4      > FE_RESET_R                                       $6      !1, ->13
          5    > > FE_FETCH_R                                               $6, !4, ->13
    9     6    >   INIT_FCALL_BY_NAME                                       'count_posts'
          7        SEND_VAR_EX                                              !4
          8        SEND_VAR_EX                                              !1
          9        SEND_VAR_EX                                              !4
         10        DO_FCALL                                      0  $7      
         11        ASSIGN_OP                                     1          !3, $7
    8    12      > JMP                                                      ->5
         13    >   FE_FREE                                                  $6
   11    14        FETCH_DIM_R                                      ~9      !2, !0
         15        ASSIGN_OP                                     1          !3, ~9
   12    16      > RETURN                                                   !3
   13    17*     > RETURN                                                   null

End of function count_posts

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
199.2 ms | 1399 KiB | 14 Q