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/0Bd1g
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 = 48
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 48
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 47
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 39
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 25
Branch analysis from position: 47
Branch analysis from position: 14
Branch analysis from position: 11
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
filename:       /in/0Bd1g
function name:  coolPluck
number of ops:  51
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, ->48
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->48
          5    >   ASSIGN                                                   !4, ~8
    8     6        IS_IDENTICAL                                     ~10     !4, !1
          7      > JMPZ_EX                                          ~10     ~10, ->11
          8    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !0, !4
          9        BOOL_NOT                                         ~12     ~11
         10        BOOL                                             ~10     ~12
         11    > > JMPZ                                                     ~10, ->14
    9    12    >   ASSIGN_DIM                                               !2, !4
         13        OP_DATA                                                  !3
   11    14    >   TYPE_CHECK                                  128          !3
         15      > JMPZ                                                     ~14, ->47
   12    16    >   INIT_FCALL_BY_NAME                                       'coolPluck'
         17        SEND_VAR_EX                                              !3
         18        SEND_VAR_EX                                              !1
         19        DO_FCALL                                      0  $15     
         20        ASSIGN                                                   !5, $15
   13    21        ISSET_ISEMPTY_DIM_OBJ                         0  ~17     !5, !1
         22      > JMPZ_EX                                          ~17     ~17, ->25
         23    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~18     !2, !1
         24        BOOL                                             ~17     ~18
         25    > > JMPZ                                                     ~17, ->39
   15    26    >   INIT_FCALL                                               'array_merge'
         27        FETCH_DIM_R                                      ~19     !5, !1
         28        CAST                                          7  ~20     ~19
         29        SEND_VAL                                                 ~20
         30        FETCH_DIM_R                                      ~21     !2, !1
         31        CAST                                          7  ~22     ~21
         32        SEND_VAL                                                 ~22
         33        DO_ICALL                                         $23     
         34        ASSIGN                                                   !2, $23
   17    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !2
         37        DO_ICALL                                                 
         38      > JMP                                                      ->47
   20    39    >   INIT_FCALL                                               'array_merge'
         40        SEND_VAR                                                 !5
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                         $26     
         43        ASSIGN                                                   !2, $26
   22    44        INIT_FCALL                                               'var_dump'
         45        SEND_VAR                                                 !2
         46        DO_ICALL                                                 
    7    47    > > JMP                                                      ->4
         48    >   FE_FREE                                                  $7
   27    49      > RETURN                                                   !2
   28    50*     > RETURN                                                   null

End of function coolpluck

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.1 ms | 1394 KiB | 18 Q