3v4l.org

run code in 300+ PHP versions simultaneously
<?php function searchFromArray($array, $keyword) { echo "\n".$keyword."\n"; $result = array(); if (count($keyword) == 2) { $result[] = $array[$keyword[0]]; } else { foreach ($keyword as $kw => $vw) { if (isset($array[$vw])) { if (is_array($array[$vw])) { unset($keyword[0]); searchFromArray($array[$vw], $keyword); } else { $result[] = $array[$vw]; } } } } return $result; } $array_search = array( 'offset' => '', 'count' => '', 'max_count' => '', 'content_list' => array(array( 'content' => array( 'id'=>'1', 'type'=>'', 'name_title'=>'', 'parent_id'=>'', 'rating_type'=>'', 'link_url'=>'', 'tag' => array( 'id' => 'tag_id_1', 'name' => 'tag_name_1' ), 'image_dir'=>'', 'image_url'=>'', 'image_dir_thumb'=>'x', 'image_url_thumb'=>'' ), 'content' => array( 'id'=>'2', 'type'=>'', 'name_title'=>'', 'parent_id'=>'', 'rating_type'=>'', 'link_url'=>'', 'tag' => array( 'id' => 'tag_id_2', 'name' => 'tag_name_2' ), 'image_dir'=>'', 'image_url'=>'', 'image_dir_thumb'=>'y', 'image_url_thumb'=>'' ) ) ) ); $keyword = array('content_list', 'content', 'tag'); $result = searchFromArray($array_search, $keyword); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UPO8P
function name:  (null)
number of ops:  11
compiled vars:  !0 = $array_search, !1 = $keyword, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ASSIGN                                                   !0, <array>
   73     1        ASSIGN                                                   !1, <array>
   74     2        INIT_FCALL                                               'searchfromarray'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   75     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function searchfromarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 34
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 34
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 33
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 33
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/UPO8P
function name:  searchFromArray
number of ops:  37
compiled vars:  !0 = $array, !1 = $keyword, !2 = $result, !3 = $vw, !4 = $kw
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        CONCAT                                           ~5      '%0A', !1
          3        CONCAT                                           ~6      ~5, '%0A'
          4        ECHO                                                     ~6
    5     5        ASSIGN                                                   !2, <array>
    6     6        COUNT                                            ~8      !1
          7        IS_EQUAL                                                 ~8, 2
          8      > JMPZ                                                     ~9, ->14
    8     9    >   FETCH_DIM_R                                      ~11     !1, 0
         10        FETCH_DIM_R                                      ~12     !0, ~11
         11        ASSIGN_DIM                                               !2
         12        OP_DATA                                                  ~12
         13      > JMP                                                      ->35
   12    14    > > FE_RESET_R                                       $13     !1, ->34
         15    > > FE_FETCH_R                                       ~14     $13, !3, ->34
         16    >   ASSIGN                                                   !4, ~14
   14    17        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !3
         18      > JMPZ                                                     ~16, ->33
   16    19    >   FETCH_DIM_R                                      ~17     !0, !3
         20        TYPE_CHECK                                  128          ~17
         21      > JMPZ                                                     ~18, ->30
   18    22    >   UNSET_DIM                                                !1, 0
   19    23        INIT_FCALL_BY_NAME                                       'searchFromArray'
         24        CHECK_FUNC_ARG                                           
         25        FETCH_DIM_FUNC_ARG                               $19     !0, !3
         26        SEND_FUNC_ARG                                            $19
         27        SEND_VAR_EX                                              !1
         28        DO_FCALL                                      0          
         29      > JMP                                                      ->33
   23    30    >   FETCH_DIM_R                                      ~22     !0, !3
         31        ASSIGN_DIM                                               !2
         32        OP_DATA                                                  ~22
   12    33    > > JMP                                                      ->15
         34    >   FE_FREE                                                  $13
   28    35    > > RETURN                                                   !2
   29    36*     > RETURN                                                   null

End of function searchfromarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.29 ms | 1402 KiB | 16 Q