3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_pluck($key, $input) { if (is_array($key) || !is_array($input)) return array(); $array = array(); foreach($input as $v) { if(array_key_exists($key, $v)) $array[]=$v[$key]; } return $array; } $testArray = array('test' => array('a' => array('percy', 'a' => 'mitch'), 'b', 'c')); $res = array_pluck('a', $testArray); print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEnop
function name:  (null)
number of ops:  10
compiled vars:  !0 = $testArray, !1 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   16     1        INIT_FCALL                                               'array_pluck'
          2        SEND_VAL                                                 'a'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   18     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function array_pluck:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 17
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 7
filename:       /in/NEnop
function name:  array_pluck
number of ops:  21
compiled vars:  !0 = $key, !1 = $input, !2 = $array, !3 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        TYPE_CHECK                                  128  ~4      !0
          3      > JMPNZ_EX                                         ~4      ~4, ->7
          4    >   TYPE_CHECK                                  128  ~5      !1
          5        BOOL_NOT                                         ~6      ~5
          6        BOOL                                             ~4      ~6
          7    > > JMPZ                                                     ~4, ->9
          8    > > RETURN                                                   <array>
    5     9    >   ASSIGN                                                   !2, <array>
    6    10      > FE_RESET_R                                       $8      !1, ->18
         11    > > FE_FETCH_R                                               $8, !3, ->18
    7    12    >   ARRAY_KEY_EXISTS                                         !0, !3
         13      > JMPZ                                                     ~9, ->17
         14    >   FETCH_DIM_R                                      ~11     !3, !0
         15        ASSIGN_DIM                                               !2
         16        OP_DATA                                                  ~11
    6    17    > > JMP                                                      ->11
         18    >   FE_FREE                                                  $8
    9    19      > RETURN                                                   !2
   10    20*     > RETURN                                                   null

End of function array_pluck

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.5 ms | 1394 KiB | 16 Q