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)?$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/cmuQK
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%2FcmuQK%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%2FcmuQK%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cmuQK
function name:  {closure}
number of ops:  14
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, ->10
          5    >   FETCH_DIM_R                                      ~5      !1, !2
          6        ASSIGN_DIM                                       ~4      !0
          7        OP_DATA                                                  ~5
          8        QM_ASSIGN                                        ~6      ~4
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~6      !0
         11    >   ASSIGN                                           ~7      !0, ~6
         12      > RETURN                                                   ~7
    8    13*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.86 ms | 1396 KiB | 17 Q