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

End of function array_search_recursive_pair

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.02 ms | 1403 KiB | 17 Q