3v4l.org

run code in 500+ PHP versions simultaneously
<?php $categories = array( array( "id" => 1, "title" => "Обувь", 'children' => array( array( 'id' => 2, 'title' => 'Ботинки', 'children' => array( array('id' => 3, 'title' => 'Кожа'), array('id' => 4, 'title' => 'Текстиль'), ), ), array('id' => 5, 'title' => 'Кроссовки',), )), array( "id" => 6, "title" => "Спорт", 'children' => array( array( 'id' => 7, 'title' => 'Мячи' ) ) ), ); function searchCategory($categories, $id) { foreach($categories as $category) { if($category['id'] == $id) echo $category['title'] . '<br>'; if(isset($category['children'])) searchCategory($category['children'],$id); } }; searchCategory($categories,4);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CR7CD
function name:  (null)
number of ops:  6
compiled vars:  !0 = $categories
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   34     1        INIT_FCALL                                                   'searchcategory'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     4
          4        DO_FCALL                                          0          
          5      > RETURN                                                       1

Function searchcategory:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 10
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/CR7CD
function name:  searchCategory
number of ops:  21
compiled vars:  !0 = $categories, !1 = $id, !2 = $category
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   26     2      > FE_RESET_R                                           $3      !0, ->19
          3    > > FE_FETCH_R                                                   $3, !2, ->19
   27     4    >   FETCH_DIM_R                                          ~4      !2, 'id'
          5        IS_EQUAL                                                     !1, ~4
          6      > JMPZ                                                         ~5, ->10
   28     7    >   FETCH_DIM_R                                          ~6      !2, 'title'
          8        CONCAT                                               ~7      ~6, '%3Cbr%3E'
          9        ECHO                                                         ~7
   29    10    >   ISSET_ISEMPTY_DIM_OBJ                             0          !2, 'children'
         11      > JMPZ                                                         ~8, ->18
   30    12    >   INIT_FCALL_BY_NAME                                           'searchCategory'
         13        CHECK_FUNC_ARG                                               
         14        FETCH_DIM_FUNC_ARG                                   $9      !2, 'children'
         15        SEND_FUNC_ARG                                                $9
         16        SEND_VAR_EX                                                  !1
         17        DO_FCALL                                          0          
   26    18    > > JMP                                                          ->3
         19    >   FE_FREE                                                      $3
   32    20      > RETURN                                                       null

End of function searchcategory

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.65 ms | 2031 KiB | 14 Q