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)), RecursiveIteratorIterator::SELF_FIRST) 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/iWW8p
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 = 15, Position 2 = 35
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 35
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 34
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 46) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 31
Branch analysis from position: 22
Branch analysis from position: 34
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/iWW8p
function name:  array_search_recursive_pair
number of ops:  38
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        SEND_VAL_EX                                              1
         13        DO_FCALL                                      0          
         14      > FE_RESET_R                                       $11     $5, ->35
         15    > > FE_FETCH_R                                               $11, !4, ->35
   17    16    >   ARRAY_KEY_EXISTS                                         !1, !4
         17      > JMPZ                                                     ~12, ->34
   18    18    > > JMPZ_EX                                          ~13     !3, ->22
         19    >   FETCH_DIM_R                                      ~14     !4, !1
         20        IS_IDENTICAL                                     ~15     !2, ~14
         21        BOOL                                             ~13     ~15
         22    > > JMPZ                                                     ~13, ->26
   19    23    >   FE_FREE                                                  $11
         24      > RETURN                                                   !4
         25*       JMP                                                      ->34
   20    26    >   BOOL_NOT                                         ~16     !3
         27      > JMPZ_EX                                          ~16     ~16, ->31
         28    >   FETCH_DIM_R                                      ~17     !4, !1
         29        IS_EQUAL                                         ~18     !2, ~17
         30        BOOL                                             ~16     ~18
         31    > > JMPZ                                                     ~16, ->34
   21    32    >   FE_FREE                                                  $11
         33      > RETURN                                                   !4
   16    34    > > JMP                                                      ->15
         35    >   FE_FREE                                                  $11
   26    36      > RETURN                                                   <false>
   27    37*     > RETURN                                                   null

End of function array_search_recursive_pair

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.22 ms | 1403 KiB | 17 Q