3v4l.org

run code in 300+ PHP versions simultaneously
<?php function coolPluck($array, $lookup) { $output = array(); foreach($array as $k => $v) { if($k === $lookup && (isset($array[$k]))) { $output[$k] = $v; } if(is_array($v)) { $results = coolPluck($v, $lookup); if(isset($results[$lookup]) && isset($output[$lookup])) { $output = array_merge((array) $results[$lookup], (array) $output[$lookup]); var_dump($output); } else { $output = array_merge($results, $output); var_dump($output); } } } return $output; } $testArray = array('test' => array('percy' => array('percy' => 'hatcherson'), 'percy' => array('mitchell', 'anderson'))); var_dump(coolPluck($testArray, 'percy'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2FNT4
function name:  (null)
number of ops:  9
compiled vars:  !0 = $testArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ASSIGN                                                   !0, <array>
   34     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'coolpluck'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'percy'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function coolpluck:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 47
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 47
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 46
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 38
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
Branch analysis from position: 46
Branch analysis from position: 13
Branch analysis from position: 10
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/2FNT4
function name:  coolPluck
number of ops:  50
compiled vars:  !0 = $array, !1 = $lookup, !2 = $output, !3 = $v, !4 = $k, !5 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    7     3      > FE_RESET_R                                       $7      !0, ->47
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->47
          5    >   ASSIGN                                                   !4, ~8
    8     6        IS_IDENTICAL                                     ~10     !4, !1
          7      > JMPZ_EX                                          ~10     ~10, ->10
          8    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !0, !4
          9        BOOL                                             ~10     ~11
         10    > > JMPZ                                                     ~10, ->13
    9    11    >   ASSIGN_DIM                                               !2, !4
         12        OP_DATA                                                  !3
   11    13    >   TYPE_CHECK                                  128          !3
         14      > JMPZ                                                     ~13, ->46
   12    15    >   INIT_FCALL_BY_NAME                                       'coolPluck'
         16        SEND_VAR_EX                                              !3
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $14     
         19        ASSIGN                                                   !5, $14
   13    20        ISSET_ISEMPTY_DIM_OBJ                         0  ~16     !5, !1
         21      > JMPZ_EX                                          ~16     ~16, ->24
         22    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~17     !2, !1
         23        BOOL                                             ~16     ~17
         24    > > JMPZ                                                     ~16, ->38
   15    25    >   INIT_FCALL                                               'array_merge'
         26        FETCH_DIM_R                                      ~18     !5, !1
         27        CAST                                          7  ~19     ~18
         28        SEND_VAL                                                 ~19
         29        FETCH_DIM_R                                      ~20     !2, !1
         30        CAST                                          7  ~21     ~20
         31        SEND_VAL                                                 ~21
         32        DO_ICALL                                         $22     
         33        ASSIGN                                                   !2, $22
   17    34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                                 
         37      > JMP                                                      ->46
   20    38    >   INIT_FCALL                                               'array_merge'
         39        SEND_VAR                                                 !5
         40        SEND_VAR                                                 !2
         41        DO_ICALL                                         $25     
         42        ASSIGN                                                   !2, $25
   22    43        INIT_FCALL                                               'var_dump'
         44        SEND_VAR                                                 !2
         45        DO_ICALL                                                 
    7    46    > > JMP                                                      ->4
         47    >   FE_FREE                                                  $7
   27    48      > RETURN                                                   !2
   28    49*     > RETURN                                                   null

End of function coolpluck

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.33 ms | 1403 KiB | 18 Q