3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(0 => array("key" => "val"), 1 => array("key" => "anotherval")); $key = "key"; $result = array_reduce($arr, function(&$cur, $item) use ($key) { return $cur=array_key_exists($key, $item)?array_merge($cur, [$item[$key]]):$cur; }, []); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vribM
function name:  (null)
number of ops:  14
compiled vars:  !0 = $arr, !1 = $key, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 'key'
    5     2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvribM%3A5%240'
          5        BIND_LEXICAL                                             ~5, !1
    8     6        SEND_VAL                                                 ~5
          7        SEND_VAL                                                 <array>
          8        DO_ICALL                                         $6      
    5     9        ASSIGN                                                   !2, $6
    9    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvribM%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vribM
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $cur, !1 = $item, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    7     3        ARRAY_KEY_EXISTS                                         !2, !1
          4      > JMPZ                                                     ~3, ->13
          5    >   INIT_FCALL                                               'array_merge'
          6        SEND_VAR                                                 !0
          7        FETCH_DIM_R                                      ~4      !1, !2
          8        INIT_ARRAY                                       ~5      ~4
          9        SEND_VAL                                                 ~5
         10        DO_ICALL                                         $6      
         11        QM_ASSIGN                                        ~7      $6
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~7      !0
         14    >   ASSIGN                                           ~8      !0, ~7
         15      > RETURN                                                   ~8
    8    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvribM%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.09 ms | 1396 KiB | 19 Q