3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = array('SS2014','SU2014','FW2014','SS2013','FW2013','NW2012'); $cleanUpResult = array(); $counter = 0; $previousYear = ''; $currentIndex = 10; $previousYear = '2014'; foreach($strings as $row){ // if($counter == 0){ // $previousYear = substr($row, -4); // } if($previousYear !== substr($row, -4)){ $currentIndex = $currentIndex + 10; } if($counter > 0){ $previousYear = substr($row, -4); } switch(substr($row, 0, 2)){ case 'SS': $cleanUpResult[$currentIndex + 1] = $row; break; case 'SU': $cleanUpResult[$currentIndex + 2] = $row; break; case 'FW': $cleanUpResult[$currentIndex + 3] = $row; break; case 'WI': $cleanUpResult[$currentIndex + 4] = $row; break; case 'XM': $cleanUpResult[$currentIndex + 5] = $row; break; case 'CO': $cleanUpResult[$currentIndex + 6] = $row; break; case 'NW': $cleanUpResult[$currentIndex + 7] = $row; break; } $cleanUpResult[] = $row; $counter++; } var_dump($cleanUpResult);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 77
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 77
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
9 jumps found. (Code = 188) Position 1 = 44, Position 2 = 48, Position 3 = 52, Position 4 = 56, Position 5 = 60, Position 6 = 64, Position 7 = 68, Position 8 = 72, Position 9 = 29
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 72
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 44
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 48
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 52
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 56
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 60
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 64
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 68
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 68
Branch analysis from position: 64
Branch analysis from position: 60
Branch analysis from position: 56
Branch analysis from position: 52
Branch analysis from position: 48
Branch analysis from position: 44
Branch analysis from position: 23
Branch analysis from position: 16
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 77
filename:       /in/MZJ1J
function name:  (null)
number of ops:  82
compiled vars:  !0 = $strings, !1 = $cleanUpResult, !2 = $counter, !3 = $previousYear, !4 = $currentIndex, !5 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, 0
    7     3        ASSIGN                                                   !3, ''
    8     4        ASSIGN                                                   !4, 10
    9     5        ASSIGN                                                   !3, '2014'
   10     6      > FE_RESET_R                                       $12     !0, ->77
          7    > > FE_FETCH_R                                               $12, !5, ->77
   15     8    >   INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !5
         10        SEND_VAL                                                 -4
         11        DO_ICALL                                         $13     
         12        IS_NOT_IDENTICAL                                         !3, $13
         13      > JMPZ                                                     ~14, ->16
   16    14    >   ADD                                              ~15     !4, 10
         15        ASSIGN                                                   !4, ~15
   19    16    >   IS_SMALLER                                               0, !2
         17      > JMPZ                                                     ~17, ->23
   20    18    >   INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !5
         20        SEND_VAL                                                 -4
         21        DO_ICALL                                         $18     
         22        ASSIGN                                                   !3, $18
   25    23    >   INIT_FCALL                                               'substr'
         24        SEND_VAR                                                 !5
         25        SEND_VAL                                                 0
         26        SEND_VAL                                                 2
         27        DO_ICALL                                         $20     
         28      > SWITCH_STRING                                            $20, [ 'SS':->44, 'SU':->48, 'FW':->52, 'WI':->56, 'XM':->60, 'CO':->64, 'NW':->68, ], ->72
   26    29    >   CASE                                                     $20, 'SS'
         30      > JMPNZ                                                    ~21, ->44
   29    31    >   CASE                                                     $20, 'SU'
         32      > JMPNZ                                                    ~21, ->48
   32    33    >   CASE                                                     $20, 'FW'
         34      > JMPNZ                                                    ~21, ->52
   35    35    >   CASE                                                     $20, 'WI'
         36      > JMPNZ                                                    ~21, ->56
   38    37    >   CASE                                                     $20, 'XM'
         38      > JMPNZ                                                    ~21, ->60
   41    39    >   CASE                                                     $20, 'CO'
         40      > JMPNZ                                                    ~21, ->64
   44    41    >   CASE                                                     $20, 'NW'
         42      > JMPNZ                                                    ~21, ->68
         43    > > JMP                                                      ->72
   27    44    >   ADD                                              ~22     !4, 1
         45        ASSIGN_DIM                                               !1, ~22
         46        OP_DATA                                                  !5
   28    47      > JMP                                                      ->72
   30    48    >   ADD                                              ~24     !4, 2
         49        ASSIGN_DIM                                               !1, ~24
         50        OP_DATA                                                  !5
   31    51      > JMP                                                      ->72
   33    52    >   ADD                                              ~26     !4, 3
         53        ASSIGN_DIM                                               !1, ~26
         54        OP_DATA                                                  !5
   34    55      > JMP                                                      ->72
   36    56    >   ADD                                              ~28     !4, 4
         57        ASSIGN_DIM                                               !1, ~28
         58        OP_DATA                                                  !5
   37    59      > JMP                                                      ->72
   39    60    >   ADD                                              ~30     !4, 5
         61        ASSIGN_DIM                                               !1, ~30
         62        OP_DATA                                                  !5
   40    63      > JMP                                                      ->72
   42    64    >   ADD                                              ~32     !4, 6
         65        ASSIGN_DIM                                               !1, ~32
         66        OP_DATA                                                  !5
   43    67      > JMP                                                      ->72
   45    68    >   ADD                                              ~34     !4, 7
         69        ASSIGN_DIM                                               !1, ~34
         70        OP_DATA                                                  !5
   46    71      > JMP                                                      ->72
         72    >   FREE                                                     $20
   50    73        ASSIGN_DIM                                               !1
         74        OP_DATA                                                  !5
   51    75        PRE_INC                                                  !2
   10    76      > JMP                                                      ->7
         77    >   FE_FREE                                                  $12
   53    78        INIT_FCALL                                               'var_dump'
         79        SEND_VAR                                                 !1
         80        DO_ICALL                                                 
         81      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.75 ms | 1408 KiB | 17 Q