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[$index] = array_column($array, $index); foreach ($array as $k => $v) { if (is_array($v)) { $helper[$index] = 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/sSrqi
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 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 22
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/sSrqi
function name:  recursiveArrayColumn
number of ops:  25
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                                         $6      
          7        ASSIGN_DIM                                               !2, !1
          8        OP_DATA                                                  $6
   30     9      > FE_RESET_R                                       $7      !0, ->22
         10    > > FE_FETCH_R                                       ~8      $7, !3, ->22
         11    >   ASSIGN                                                   !4, ~8
   32    12        TYPE_CHECK                                  128          !3
         13      > JMPZ                                                     ~10, ->21
   33    14    >   INIT_FCALL_BY_NAME                                       'recursiveArrayColumn'
         15        SEND_VAR_EX                                              !3
         16        SEND_VAR_EX                                              !1
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0  $12     
         19        ASSIGN_DIM                                               !2, !1
         20        OP_DATA                                                  $12
   30    21    > > JMP                                                      ->10
         22    >   FE_FREE                                                  $7
   40    23      > RETURN                                                   !2
   41    24*     > RETURN                                                   null

End of function recursivearraycolumn

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.35 ms | 1403 KiB | 18 Q