3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['1', 'a'], ['2', 'b'], ['3', 'c'], ['3', 'd'], ['2', 'e'], ['3', 'f'], ['2', 'g'], ['3', 'h'], ['1', 'i'], ['2', 'j'], ['3', 'k'], ]; $savedLevelOne = null; $savedLevels = []; $prevLevel = null; foreach ($arr as $arrItem) { [$level, $value] = $arrItem; if ($level !== '3' && $prevLevel === '3') { var_dump([$savedLevelOne, ...$savedLevels]); $savedLevels = []; } if ($level === '1') { $savedLevelOne = $value; } else { $savedLevels[] = $value; } $prevLevel = $level; } var_dump([$savedLevelOne, ...$savedLevels]);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 31
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 31
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 23
Branch analysis from position: 16
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/hJnmQ
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arr, !1 = $savedLevelOne, !2 = $savedLevels, !3 = $prevLevel, !4 = $arrItem, !5 = $level, !6 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   19     1        ASSIGN                                                   !1, null
   20     2        ASSIGN                                                   !2, <array>
   21     3        ASSIGN                                                   !3, null
   23     4      > FE_RESET_R                                       $11     !0, ->31
          5    > > FE_FETCH_R                                               $11, !4, ->31
   25     6    >   QM_ASSIGN                                        ~12     !4
          7        FETCH_LIST_R                                     $13     ~12, 0
          8        ASSIGN                                                   !5, $13
          9        FETCH_LIST_R                                     $15     ~12, 1
         10        ASSIGN                                                   !6, $15
         11        FREE                                                     ~12
   27    12        IS_NOT_IDENTICAL                                 ~17     !5, '3'
         13      > JMPZ_EX                                          ~17     ~17, ->16
         14    >   IS_IDENTICAL                                     ~18     !3, '3'
         15        BOOL                                             ~17     ~18
         16    > > JMPZ                                                     ~17, ->23
   28    17    >   INIT_FCALL                                               'var_dump'
         18        INIT_ARRAY                                       ~19     !1
         19        ADD_ARRAY_UNPACK                                 ~19     !2
         20        SEND_VAL                                                 ~19
         21        DO_ICALL                                                 
   29    22        ASSIGN                                                   !2, <array>
   32    23    >   IS_IDENTICAL                                             !5, '1'
         24      > JMPZ                                                     ~22, ->27
   33    25    >   ASSIGN                                                   !1, !6
   32    26      > JMP                                                      ->29
   35    27    >   ASSIGN_DIM                                               !2
         28        OP_DATA                                                  !6
   37    29    >   ASSIGN                                                   !3, !5
   23    30      > JMP                                                      ->5
         31    >   FE_FREE                                                  $11
   40    32        INIT_FCALL                                               'var_dump'
         33        INIT_ARRAY                                       ~26     !1
         34        ADD_ARRAY_UNPACK                                 ~26     !2
         35        SEND_VAL                                                 ~26
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.97 ms | 1010 KiB | 14 Q