3v4l.org

run code in 300+ PHP versions simultaneously
<?php function element_search(array $array, $search, $mode = 'value', $return = false) { foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $value) { if ($search === ${${"mode"}}){ return $return ? ${${"mode"}} : true; } } return false; } $arr = [ "apple", ["banana", "strawberry", "apple"] ]; var_dump(element_search($arr, 'apple'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5CJdQ
function name:  (null)
number of ops:  9
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'element_search'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'apple'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function element_search:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 24
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 24
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/5CJdQ
function name:  element_search
number of ops:  27
compiled vars:  !0 = $array, !1 = $search, !2 = $mode, !3 = $return, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      'value'
          3        RECV_INIT                                        !3      <false>
    4     4        NEW                                              $6      'RecursiveIteratorIterator'
          5        NEW                                              $7      'RecursiveArrayIterator'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        SEND_VAR_NO_REF_EX                                       $7
          9        DO_FCALL                                      0          
         10      > FE_RESET_R                                       $10     $6, ->24
         11    > > FE_FETCH_R                                       ~11     $10, !4, ->24
         12    >   ASSIGN                                                   !5, ~11
    5    13        FETCH_R                      local               ~13     !2
         14        IS_IDENTICAL                                             !1, ~13
         15      > JMPZ                                                     ~14, ->23
    6    16    > > JMPZ                                                     !3, ->20
         17    >   FETCH_R                      local               ~15     !2
         18        QM_ASSIGN                                        ~16     ~15
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~16     <true>
         21    >   FE_FREE                                                  $10
         22      > RETURN                                                   ~16
    4    23    > > JMP                                                      ->11
         24    >   FE_FREE                                                  $10
   11    25      > RETURN                                                   <false>
   12    26*     > RETURN                                                   null

End of function element_search

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.3 ms | 1403 KiB | 16 Q