3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'vehicle info' => [ 'one' => [ 'submodel' => 'LX', 'engine' => 2.3 ], 'two' => [ 'color' => 'blue', 'year' => 2007, 'wheels' => 4 ], 'three' => [ 'submodel' => 'LX', 'make' => 'Ford', 'model' => 'F-150', 'offroad' => 'No' ] ] ]; $soughtKeys = array_flip(['submodel', 'offroad']); function earlyReturningRecursion(array $array, array $soughtKeys, array &$result = []): array { foreach ($array as $key => $value) { if (!array_diff_key($soughtKeys, $result)) { return $result; } elseif (is_array($value)) { earlyReturningRecursion($value, $soughtKeys, $result); } elseif (isset($soughtKeys[$key]) && !isset($result[$key])) { $result[$key] = "$key is $value"; } } return $result; } var_export(earlyReturningRecursion($array, $soughtKeys));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NfXnF
function name:  (null)
number of ops:  13
compiled vars:  !0 = $array, !1 = $soughtKeys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   23     1        INIT_FCALL                                               'array_flip'
          2        SEND_VAL                                                 <array>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   38     5        INIT_FCALL                                               'var_export'
          6        INIT_FCALL                                               'earlyreturningrecursion'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $5      
         10        SEND_VAR                                                 $5
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function earlyreturningrecursion:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 36
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 36
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 35
Branch analysis from position: 29
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/NfXnF
function name:  earlyReturningRecursion
number of ops:  41
compiled vars:  !0 = $array, !1 = $soughtKeys, !2 = $result, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
   27     3      > FE_RESET_R                                       $5      !0, ->36
          4    > > FE_FETCH_R                                       ~6      $5, !3, ->36
          5    >   ASSIGN                                                   !4, ~6
   28     6        INIT_FCALL                                               'array_diff_key'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $8      
         10        BOOL_NOT                                         ~9      $8
         11      > JMPZ                                                     ~9, ->16
   29    12    >   VERIFY_RETURN_TYPE                                       !2
         13        FE_FREE                                                  $5
         14      > RETURN                                                   !2
   28    15*       JMP                                                      ->35
   30    16    >   TYPE_CHECK                                  128          !3
         17      > JMPZ                                                     ~10, ->24
   31    18    >   INIT_FCALL_BY_NAME                                       'earlyReturningRecursion'
         19        SEND_VAR_EX                                              !3
         20        SEND_VAR_EX                                              !1
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0          
   30    23      > JMP                                                      ->35
   32    24    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~12     !1, !4
         25      > JMPZ_EX                                          ~12     ~12, ->29
         26    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !2, !4
         27        BOOL_NOT                                         ~14     ~13
         28        BOOL                                             ~12     ~14
         29    > > JMPZ                                                     ~12, ->35
   33    30    >   ROPE_INIT                                     3  ~17     !4
         31        ROPE_ADD                                      1  ~17     ~17, '+is+'
         32        ROPE_END                                      2  ~16     ~17, !3
         33        ASSIGN_DIM                                               !2, !4
         34        OP_DATA                                                  ~16
   27    35    > > JMP                                                      ->4
         36    >   FE_FREE                                                  $5
   36    37        VERIFY_RETURN_TYPE                                       !2
         38      > RETURN                                                   !2
   37    39*       VERIFY_RETURN_TYPE                                       
         40*     > RETURN                                                   null

End of function earlyreturningrecursion

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.89 ms | 1007 KiB | 17 Q