3v4l.org

run code in 300+ PHP versions simultaneously
<?php function searchNested($arr,$keyword){ $found = array(); foreach($arr as $item){ if($item['categorySlug']==$keyword){ $found[] = $item; }else{ $found = array_merge($found,__FUNC__($item['categoryNested'],$keyword)); } } return $found; } var_dump(searchNested(array(array ( 'categoryName' => 'Moto', 'categoryTitle' => 'Moto', 'categorySlug' => 'moto-and-tech', 'categoryAttr' => array ( 0 => 'test1', 1 => 'test2', 2 => 'test3', 3 => 'test4' ), 'categoryNested' => array ( 0 => array ( 'categoryName' => 'anything', 'categoryTitle' => 'anything', 'categorySlug' => 'anything', 'categoryAttr' => array ( 0 => 'test1', 1 => 'test1', 2 => 'test1', 3 => 'test1' ), 'categoryNested' => array() ), 1 => array ( 'categoryName' => 'any', 'categoryTitle' => 'any', 'categorySlug' => 'any', 'categoryAttr' => array ( 0 => 'test1', 1 => 'test1', 2 => 'test1', 3 => 'test1' ), 'categoryNested' => array() )))),'any'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MXRfh
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'searchnested'
   16     2        SEND_VAL                                                 <array>
   55     3        SEND_VAL                                                 'any'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function searchnested:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 23
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/MXRfh
function name:  searchNested
number of ops:  26
compiled vars:  !0 = $arr, !1 = $keyword, !2 = $found, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                                   !2, <array>
    4     3      > FE_RESET_R                                       $5      !0, ->23
          4    > > FE_FETCH_R                                               $5, !3, ->23
    5     5    >   FETCH_DIM_R                                      ~6      !3, 'categorySlug'
          6        IS_EQUAL                                                 !1, ~6
          7      > JMPZ                                                     ~7, ->11
    6     8    >   ASSIGN_DIM                                               !2
          9        OP_DATA                                                  !3
         10      > JMP                                                      ->22
    8    11    >   INIT_FCALL                                               'array_merge'
         12        SEND_VAR                                                 !2
         13        INIT_FCALL_BY_NAME                                       '__FUNC__'
         14        CHECK_FUNC_ARG                                           
         15        FETCH_DIM_FUNC_ARG                               $9      !3, 'categoryNested'
         16        SEND_FUNC_ARG                                            $9
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $10     
         19        SEND_VAR                                                 $10
         20        DO_ICALL                                         $11     
         21        ASSIGN                                                   !2, $11
    4    22    > > JMP                                                      ->4
         23    >   FE_FREE                                                  $5
   11    24      > RETURN                                                   !2
   12    25*     > RETURN                                                   null

End of function searchnested

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.04 ms | 1403 KiB | 18 Q