3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 1 => [ 1 => [ 'anna', 'alice' ], 2 => [ 'bob', 'bartold' ] ], 2 => [ 1 => [ 'carol' ], 2 => [ 'david' ] ] ]; $result = []; $currentIndex = 1; $increment = 0; array_walk_recursive($array, function($value, $key) use (&$result, &$currentIndex, &$increment) { if (!is_array($value)) { $result[$currentIndex][] = $value; if ($increment == 1) { $currentIndex++; $increment = 0; } else { $increment++; } } }); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t7H82
function name:  (null)
number of ops:  16
compiled vars:  !0 = $array, !1 = $result, !2 = $currentIndex, !3 = $increment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        ASSIGN                                                   !1, <array>
   25     2        ASSIGN                                                   !2, 1
   26     3        ASSIGN                                                   !3, 0
   27     4        INIT_FCALL                                               'array_walk_recursive'
          5        SEND_REF                                                 !0
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ft7H82%3A27%240'
          7        BIND_LEXICAL                                             ~8, !1
          8        BIND_LEXICAL                                             ~8, !2
          9        BIND_LEXICAL                                             ~8, !3
   38    10        SEND_VAL                                                 ~8
         11        DO_ICALL                                                 
   40    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Ft7H82%3A27%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/t7H82
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $value, !1 = $key, !2 = $result, !3 = $currentIndex, !4 = $increment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
          4        BIND_STATIC                                              !4
   28     5        TYPE_CHECK                                  128  ~5      !0
          6        BOOL_NOT                                         ~6      ~5
          7      > JMPZ                                                     ~6, ->17
   29     8    >   FETCH_DIM_W                                      $7      !2, !3
          9        ASSIGN_DIM                                               $7
         10        OP_DATA                                                  !0
   30    11        IS_EQUAL                                                 !4, 1
         12      > JMPZ                                                     ~9, ->16
   31    13    >   PRE_INC                                                  !3
   32    14        ASSIGN                                                   !4, 0
         15      > JMP                                                      ->17
   35    16    >   PRE_INC                                                  !4
   38    17    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Ft7H82%3A27%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.14 ms | 1400 KiB | 17 Q