3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testArray = array( 'percy' => array( 'philip' => array( 'mitch' => array( 'percy' => 'hatcherson', 'mitch' => 'anderson' ) ), 'mitch' => array( 'mitchell', 'anderson', 'percy' => array( 'percy', 'hatcherson' ), 'mitchell' => 'thomas mitchell anderson', 'percy' => 'percy philip hatcherson' ) ) ); $newArray = array(); function recursiveArrayColumn ($array, $index, $helper = array()) { $helper = array_column($array, $index); foreach ($array as $k => $v) { if (is_array($v)) { $helper[] = recursiveArrayColumn($v, $index, $helper); } } return $helper; } var_dump(recursiveArrayColumn($testArray, 'percy'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/umEau
function name:  (null)
number of ops:  10
compiled vars:  !0 = $testArray, !1 = $newArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        ASSIGN                                                   !1, <array>
   44     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'recursivearraycolumn'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'percy'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function recursivearraycolumn:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 21
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/umEau
function name:  recursiveArrayColumn
number of ops:  24
compiled vars:  !0 = $array, !1 = $index, !2 = $helper, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
   28     3        INIT_FCALL                                               'array_column'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   30     8      > FE_RESET_R                                       $7      !0, ->21
          9    > > FE_FETCH_R                                       ~8      $7, !3, ->21
         10    >   ASSIGN                                                   !4, ~8
   32    11        TYPE_CHECK                                  128          !3
         12      > JMPZ                                                     ~10, ->20
   33    13    >   INIT_FCALL_BY_NAME                                       'recursiveArrayColumn'
         14        SEND_VAR_EX                                              !3
         15        SEND_VAR_EX                                              !1
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0  $12     
         18        ASSIGN_DIM                                               !2
         19        OP_DATA                                                  $12
   30    20    > > JMP                                                      ->9
         21    >   FE_FREE                                                  $7
   40    22      > RETURN                                                   !2
   41    23*     > RETURN                                                   null

End of function recursivearraycolumn

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.07 ms | 1394 KiB | 18 Q