3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lookup = array_flip(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']); $months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Sep', 'Oct', 'Dec', 'Jan', 'Feb']; $result = []; foreach ($months as $month) { if (isset($ref) && $lookup[$month] === ($lookup[$last] + 1) % 12) { $ref = strtok($ref, "-") . "-$month"; } else { unset($ref); $ref = $month; $result[] = &$ref; } $last = $month; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 32
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 32
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 16
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/HpYN5
function name:  (null)
number of ops:  37
compiled vars:  !0 = $lookup, !1 = $months, !2 = $result, !3 = $month, !4 = $ref, !5 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'array_flip'
          1        SEND_VAL                                                 <array>
          2        DO_ICALL                                         $6      
          3        ASSIGN                                                   !0, $6
    5     4        ASSIGN                                                   !1, <array>
    7     5        ASSIGN                                                   !2, <array>
    8     6      > FE_RESET_R                                       $10     !1, ->32
          7    > > FE_FETCH_R                                               $10, !3, ->32
    9     8    >   ISSET_ISEMPTY_CV                                 ~11     !4
          9      > JMPZ_EX                                          ~11     ~11, ->16
         10    >   FETCH_DIM_R                                      ~12     !0, !3
         11        FETCH_DIM_R                                      ~13     !0, !5
         12        ADD                                              ~14     ~13, 1
         13        MOD                                              ~15     ~14, 12
         14        IS_IDENTICAL                                     ~16     ~12, ~15
         15        BOOL                                             ~11     ~16
         16    > > JMPZ                                                     ~11, ->26
   10    17    >   INIT_FCALL                                               'strtok'
         18        SEND_VAR                                                 !4
         19        SEND_VAL                                                 '-'
         20        DO_ICALL                                         $17     
         21        NOP                                                      
         22        FAST_CONCAT                                      ~18     '-', !3
         23        CONCAT                                           ~19     $17, ~18
         24        ASSIGN                                                   !4, ~19
    9    25      > JMP                                                      ->30
   12    26    >   UNSET_CV                                                 !4
   13    27        ASSIGN                                                   !4, !3
   14    28        FETCH_DIM_W                                      $22     !2
         29        ASSIGN_REF                                               $22, !4
   16    30    >   ASSIGN                                                   !5, !3
    8    31      > JMP                                                      ->7
         32    >   FE_FREE                                                  $10
   18    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.9 ms | 1009 KiB | 16 Q