3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 1, 2, [ [ 'one' => '1', 'two' => 2 ] ] ]; function array_search_recursive_pair(array $array, $key, $value, $strict = false) { foreach (new RecursiveIteratorIterator(new ParentIterator(new RecursiveArrayIterator($array))) as $leaf_array) { if (array_key_exists($key, $leaf_array)) { if ($strict && $leaf_array[$key] === $value) { return $leaf_array; } elseif (!$strict && $leaf_array[$key] == $value) { return $leaf_array; } } } return false; } var_dump(array_search_recursive_pair($arr, 'one', 1)); var_dump(array_search_recursive_pair($arr, 'one', 1, true));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cvml5
function name:  (null)
number of ops:  19
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   29     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_search_recursive_pair'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'one'
          5        SEND_VAL                                                 1
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   30     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'array_search_recursive_pair'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 'one'
         13        SEND_VAL                                                 1
         14        SEND_VAL                                                 <true>
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function array_search_recursive_pair:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 34
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 34
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 33
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 30
Branch analysis from position: 21
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/Cvml5
function name:  array_search_recursive_pair
number of ops:  37
compiled vars:  !0 = $array, !1 = $key, !2 = $value, !3 = $strict, !4 = $leaf_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <false>
   16     4        NEW                                              $5      'RecursiveIteratorIterator'
          5        NEW                                              $6      'ParentIterator'
          6        NEW                                              $7      'RecursiveArrayIterator'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $7
         10        DO_FCALL                                      0          
         11        SEND_VAR_NO_REF_EX                                       $6
         12        DO_FCALL                                      0          
         13      > FE_RESET_R                                       $11     $5, ->34
         14    > > FE_FETCH_R                                               $11, !4, ->34
   17    15    >   ARRAY_KEY_EXISTS                                         !1, !4
         16      > JMPZ                                                     ~12, ->33
   18    17    > > JMPZ_EX                                          ~13     !3, ->21
         18    >   FETCH_DIM_R                                      ~14     !4, !1
         19        IS_IDENTICAL                                     ~15     !2, ~14
         20        BOOL                                             ~13     ~15
         21    > > JMPZ                                                     ~13, ->25
   19    22    >   FE_FREE                                                  $11
         23      > RETURN                                                   !4
         24*       JMP                                                      ->33
   20    25    >   BOOL_NOT                                         ~16     !3
         26      > JMPZ_EX                                          ~16     ~16, ->30
         27    >   FETCH_DIM_R                                      ~17     !4, !1
         28        IS_EQUAL                                         ~18     !2, ~17
         29        BOOL                                             ~16     ~18
         30    > > JMPZ                                                     ~16, ->33
   21    31    >   FE_FREE                                                  $11
         32      > RETURN                                                   !4
   16    33    > > JMP                                                      ->14
         34    >   FE_FREE                                                  $11
   26    35      > RETURN                                                   <false>
   27    36*     > RETURN                                                   null

End of function array_search_recursive_pair

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.84 ms | 1403 KiB | 17 Q