3v4l.org

run code in 300+ PHP versions simultaneously
<?php function multi_array_search($search_for, $search_in) { foreach ($search_in as $element) { echo "searching " . json_encode($element) . "\n"; if ( ($element === $search_for) ){ return true; }elseif(is_array($element)){ $result = multi_array_search($search_for, $element); if($result == true) return true; } } return false; } $my_array = array( 0 => array( "name" => "john", "id" => 4 ), 1 => array( "name" => "mark", "id" => 152 ), 2 => array( "name" => "Eduard", "id" => 152 ) ); echo multi_array_search(152, $my_array) ? 'Found' : 'Not found';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Aua2W
function name:  (null)
number of ops:  11
compiled vars:  !0 = $my_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   31     1        INIT_FCALL                                               'multi_array_search'
          2        SEND_VAL                                                 152
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5      > JMPZ                                                     $2, ->8
          6    >   QM_ASSIGN                                        ~3      'Found'
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~3      'Not+found'
          9    >   ECHO                                                     ~3
         10      > RETURN                                                   1

Function multi_array_search:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 27
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 27
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/Aua2W
function name:  multi_array_search
number of ops:  30
compiled vars:  !0 = $search_for, !1 = $search_in, !2 = $element, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2      > FE_RESET_R                                       $4      !1, ->27
          3    > > FE_FETCH_R                                               $4, !2, ->27
    5     4    >   INIT_FCALL                                               'json_encode'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $5      
          7        CONCAT                                           ~6      'searching+', $5
          8        CONCAT                                           ~7      ~6, '%0A'
          9        ECHO                                                     ~7
    6    10        IS_IDENTICAL                                             !2, !0
         11      > JMPZ                                                     ~8, ->15
    7    12    >   FE_FREE                                                  $4
         13      > RETURN                                                   <true>
         14*       JMP                                                      ->26
    8    15    >   TYPE_CHECK                                  128          !2
         16      > JMPZ                                                     ~9, ->26
    9    17    >   INIT_FCALL_BY_NAME                                       'multi_array_search'
         18        SEND_VAR_EX                                              !0
         19        SEND_VAR_EX                                              !2
         20        DO_FCALL                                      0  $10     
         21        ASSIGN                                                   !3, $10
   10    22        BOOL                                             ~12     !3
         23      > JMPZ                                                     ~12, ->26
   11    24    >   FE_FREE                                                  $4
         25      > RETURN                                                   <true>
    4    26    > > JMP                                                      ->3
         27    >   FE_FREE                                                  $4
   14    28      > RETURN                                                   <false>
   15    29*     > RETURN                                                   null

End of function multi_array_search

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.69 ms | 1403 KiB | 16 Q