3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 'A', 'B', 'C', 'D' => [ 'E', 'F' => [ 'G', 'H' ] ], 'I' => [ 'J', 'K' ], 'L' ]; function categoryExist($arr, $category) : bool { $ce = false; foreach ($arr as $key => $value) { if ($category === $key) return true; if (is_array($value)) { if (categoryExist($value, $category)) return true; } else { if ($category === $value) return true; } } return false; } foreach (range('A', 'M') as $cat) echo "Category '$cat' " . (categoryExist($arr, $cat) ? '' : 'not ') . "found\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 22
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 22
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/5I5f6
function name:  (null)
number of ops:  24
compiled vars:  !0 = $arr, !1 = $cat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 'A'
          3        SEND_VAL                                                 'M'
          4        DO_ICALL                                         $3      
          5      > FE_RESET_R                                       $4      $3, ->22
          6    > > FE_FETCH_R                                               $4, !1, ->22
   21     7    >   ROPE_INIT                                     3  ~6      'Category+%27'
          8        ROPE_ADD                                      1  ~6      ~6, !1
          9        ROPE_END                                      2  ~5      ~6, '%27+'
         10        INIT_FCALL                                               'categoryexist'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0  $8      
         14      > JMPZ                                                     $8, ->17
         15    >   QM_ASSIGN                                        ~9      ''
         16      > JMP                                                      ->18
         17    >   QM_ASSIGN                                        ~9      'not+'
         18    >   CONCAT                                           ~10     ~5, ~9
         19        CONCAT                                           ~11     ~10, 'found%0A'
         20        ECHO                                                     ~11
   20    21      > JMP                                                      ->6
         22    >   FE_FREE                                                  $4
   22    23      > RETURN                                                   1

Function categoryexist:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 25
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/5I5f6
function name:  categoryExist
number of ops:  29
compiled vars:  !0 = $arr, !1 = $category, !2 = $ce, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, <false>
    8     3      > FE_RESET_R                                       $6      !0, ->25
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->25
          5    >   ASSIGN                                                   !4, ~7
    9     6        IS_IDENTICAL                                             !1, !4
          7      > JMPZ                                                     ~9, ->10
          8    >   FE_FREE                                                  $6
          9      > RETURN                                                   <true>
   10    10    >   TYPE_CHECK                                  128          !3
         11      > JMPZ                                                     ~10, ->20
   11    12    >   INIT_FCALL_BY_NAME                                       'categoryExist'
         13        SEND_VAR_EX                                              !3
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0  $11     
         16      > JMPZ                                                     $11, ->19
         17    >   FE_FREE                                                  $6
         18      > RETURN                                                   <true>
   10    19    > > JMP                                                      ->24
   14    20    >   IS_IDENTICAL                                             !1, !3
         21      > JMPZ                                                     ~12, ->24
         22    >   FE_FREE                                                  $6
         23      > RETURN                                                   <true>
    8    24    > > JMP                                                      ->4
         25    >   FE_FREE                                                  $6
   17    26      > RETURN                                                   <false>
   18    27*       VERIFY_RETURN_TYPE                                       
         28*     > RETURN                                                   null

End of function categoryexist

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
293.27 ms | 1017 KiB | 15 Q