3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $strings = array('SS2014','SU2014','FW2014','SS2013','FW2013','NW2012'); $cleanUpResult = array(); $counter = 0; $previousYear = ''; $currentIndex = 10; foreach($strings as $row){ if($counter == 0){ $previousYear = substr($row, -4); } var_dump($previousYear); if($previousYear !== substr($row, -4)){ $currentIndex += 10; } var_dump($previousYear); if($counter > 0){ $previousYear = substr($row, -4); } var_dump(substr($row, 0, 2)); var_dump(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
Jump found. Position 1 = 6, Position 2 = 103
Branch analysis from position: 6
Jump found. Position 1 = 7, Position 2 = 103
Branch analysis from position: 7
Jump found. Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
Jump found. Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
Jump found. Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
Jump found. Position 1 = 56, Position 2 = 69
Branch analysis from position: 56
Jump found. Position 1 = 58, Position 2 = 73
Branch analysis from position: 58
Jump found. Position 1 = 60, Position 2 = 77
Branch analysis from position: 60
Jump found. Position 1 = 62, Position 2 = 81
Branch analysis from position: 62
Jump found. Position 1 = 64, Position 2 = 85
Branch analysis from position: 64
Jump found. Position 1 = 66, Position 2 = 89
Branch analysis from position: 66
Jump found. Position 1 = 68, Position 2 = 93
Branch analysis from position: 68
Jump found. Position 1 = 97
Branch analysis from position: 97
Jump found. Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 93
Jump found. Position 1 = 97
Branch analysis from position: 97
Branch analysis from position: 89
Jump found. Position 1 = 97
Branch analysis from position: 97
Branch analysis from position: 85
Jump found. Position 1 = 97
Branch analysis from position: 97
Branch analysis from position: 81
Jump found. Position 1 = 97
Branch analysis from position: 97
Branch analysis from position: 77
Jump found. Position 1 = 97
Branch analysis from position: 97
Branch analysis from position: 73
Jump found. Position 1 = 97
Branch analysis from position: 97
Branch analysis from position: 69
Jump found. Position 1 = 97
Branch analysis from position: 97
Branch analysis from position: 34
Branch analysis from position: 24
Branch analysis from position: 14
Branch analysis from position: 103
Jump found. Position 1 = -2
Branch analysis from position: 103
filename:       /in/OuKeV
function name:  (null)
number of ops:  108
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      > FE_RESET_R                                       $11     !0, ->103
         6    > > FE_FETCH_R                                               $11, !5, ->103
  10     7    >   IS_EQUAL                                         ~12     !2, 0
         8      > JMPZ                                                     ~12, ->14
  11     9    >   INIT_FCALL                                               'substr'
        10        SEND_VAR                                                 !5
        11        SEND_VAL                                                 -4
        12        DO_ICALL                                         $13     
        13        ASSIGN                                                   !3, $13
  13    14    >   INIT_FCALL                                               'var_dump'
        15        SEND_VAR                                                 !3
        16        DO_ICALL                                                 
  14    17        INIT_FCALL                                               'substr'
        18        SEND_VAR                                                 !5
        19        SEND_VAL                                                 -4
        20        DO_ICALL                                         $16     
        21        IS_NOT_IDENTICAL                                 ~17     !3, $16
        22      > JMPZ                                                     ~17, ->24
  15    23    >   ASSIGN_ADD                                    0          !4, 10
  17    24    >   INIT_FCALL                                               'var_dump'
        25        SEND_VAR                                                 !3
        26        DO_ICALL                                                 
  18    27        IS_SMALLER                                       ~20     0, !2
        28      > JMPZ                                                     ~20, ->34
  19    29    >   INIT_FCALL                                               'substr'
        30        SEND_VAR                                                 !5
        31        SEND_VAL                                                 -4
        32        DO_ICALL                                         $21     
        33        ASSIGN                                                   !3, $21
  21    34    >   INIT_FCALL                                               'var_dump'
        35        INIT_FCALL                                               'substr'
        36        SEND_VAR                                                 !5
        37        SEND_VAL                                                 0
        38        SEND_VAL                                                 2
        39        DO_ICALL                                         $23     
        40        SEND_VAR                                                 $23
        41        DO_ICALL                                                 
  22    42        INIT_FCALL                                               'var_dump'
        43        INIT_FCALL                                               'substr'
        44        SEND_VAR                                                 !5
        45        SEND_VAL                                                 -4
        46        DO_ICALL                                         $25     
        47        SEND_VAR                                                 $25
        48        DO_ICALL                                                 
  24    49        INIT_FCALL                                               'substr'
        50        SEND_VAR                                                 !5
        51        SEND_VAL                                                 0
        52        SEND_VAL                                                 2
        53        DO_ICALL                                         $27     
  25    54        CASE                                             ~28     $27, 'SS'
        55      > JMPNZ                                                    ~28, ->69
  28    56    >   CASE                                             ~28     $27, 'SU'
        57      > JMPNZ                                                    ~28, ->73
  31    58    >   CASE                                             ~28     $27, 'FW'
        59      > JMPNZ                                                    ~28, ->77
  34    60    >   CASE                                             ~28     $27, 'WI'
        61      > JMPNZ                                                    ~28, ->81
  37    62    >   CASE                                             ~28     $27, 'XM'
        63      > JMPNZ                                                    ~28, ->85
  40    64    >   CASE                                             ~28     $27, 'CO'
        65      > JMPNZ                                                    ~28, ->89
  43    66    >   CASE                                             ~28     $27, 'NW'
        67      > JMPNZ                                                    ~28, ->93
        68    > > JMP                                                      ->97
  26    69    >   ADD                                              ~29     !4, 1
        70        ASSIGN_DIM                                               !1, ~29
        71        OP_DATA                                                  !5
  27    72      > JMP                                                      ->97
  29    73    >   ADD                                              ~31     !4, 2
        74        ASSIGN_DIM                                               !1, ~31
        75        OP_DATA                                                  !5
  30    76      > JMP                                                      ->97
  32    77    >   ADD                                              ~33     !4, 3
        78        ASSIGN_DIM                                               !1, ~33
        79        OP_DATA                                                  !5
  33    80      > JMP                                                      ->97
  35    81    >   ADD                                              ~35     !4, 4
        82        ASSIGN_DIM                                               !1, ~35
        83        OP_DATA                                                  !5
  36    84      > JMP                                                      ->97
  38    85    >   ADD                                              ~37     !4, 5
        86        ASSIGN_DIM                                               !1, ~37
        87        OP_DATA                                                  !5
  39    88      > JMP                                                      ->97
  41    89    >   ADD                                              ~39     !4, 6
        90        ASSIGN_DIM                                               !1, ~39
        91        OP_DATA                                                  !5
  42    92      > JMP                                                      ->97
  44    93    >   ADD                                              ~41     !4, 7
        94        ASSIGN_DIM                                               !1, ~41
        95        OP_DATA                                                  !5
  45    96      > JMP                                                      ->97
        97    >   FREE                                                     $27
  49    98        ASSIGN_DIM                                               !1
        99        OP_DATA                                                  !5
  50   100        POST_INC                                         ~44     !2
       101        FREE                                                     ~44
       102      > JMP                                                      ->6
       103    >   FE_FREE                                                  $11
  52   104        INIT_FCALL                                               'var_dump'
       105        SEND_VAR                                                 !1
       106        DO_ICALL                                                 
       107      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.2.0