3v4l.org

run code in 300+ PHP versions simultaneously
<?php function find_value_by_key($key,$array) { $data = array('key'=>$key,'ret'=>false); array_walk_recursive($array,function($v,$k) use (&$data) { if ($data['ret']) return; if ($k==$data['key'] and $v) $data['ret'] = $v; },$data); return $data['ret']; } $array = [ 'foo' => '0', 'bar' => [ 'boo' => 'two', 'foo' => null, 'loo' => [ 'foo' => 0, ], ], 'goo' => [ 'foo' => '', ] ]; var_export( find_value_by_key('foo', $array) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZsZkj
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   28     1        INIT_FCALL                                               'var_export'
   29     2        INIT_FCALL                                               'find_value_by_key'
          3        SEND_VAL                                                 'foo'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   30     8      > RETURN                                                   1

Function find_value_by_key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZsZkj
function name:  find_value_by_key
number of ops:  15
compiled vars:  !0 = $key, !1 = $array, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_ARRAY                                       ~3      !0, 'key'
          3        ADD_ARRAY_ELEMENT                                ~3      <false>, 'ret'
          4        ASSIGN                                                   !2, ~3
    6     5        INIT_FCALL                                               'array_walk_recursive'
          6        SEND_REF                                                 !1
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZsZkj%3A6%240'
          8        BIND_LEXICAL                                             ~5, !2
   11     9        SEND_VAL                                                 ~5
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   12    12        FETCH_DIM_R                                      ~7      !2, 'ret'
         13      > RETURN                                                   ~7
   13    14*     > RETURN                                                   null

End of function find_value_by_key

Function %00%7Bclosure%7D%2Fin%2FZsZkj%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
Branch analysis from position: 10
filename:       /in/ZsZkj
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $v, !1 = $k, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    7     3        FETCH_DIM_R                                      ~3      !2, 'ret'
          4      > JMPZ                                                     ~3, ->6
    8     5    > > RETURN                                                   null
    9     6    >   FETCH_DIM_R                                      ~4      !2, 'key'
          7        IS_EQUAL                                         ~5      !1, ~4
          8      > JMPZ_EX                                          ~5      ~5, ->10
          9    >   BOOL                                             ~5      !0
         10    > > JMPZ                                                     ~5, ->13
   10    11    >   ASSIGN_DIM                                               !2, 'ret'
         12        OP_DATA                                                  !0
   11    13    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZsZkj%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.39 ms | 1403 KiB | 18 Q