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']; $result = []; foreach ($months as $month) { if (isset($ref) && $lookup[$month] === $lookup[$last] + 1) { $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 = 31
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 31
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/1DR1I
function name:  (null)
number of ops:  36
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, ->31
          7    > > FE_FETCH_R                                               $10, !3, ->31
    9     8    >   ISSET_ISEMPTY_CV                                 ~11     !4
          9      > JMPZ_EX                                          ~11     ~11, ->15
         10    >   FETCH_DIM_R                                      ~12     !0, !3
         11        FETCH_DIM_R                                      ~13     !0, !5
         12        ADD                                              ~14     ~13, 1
         13        IS_IDENTICAL                                     ~15     ~12, ~14
         14        BOOL                                             ~11     ~15
         15    > > JMPZ                                                     ~11, ->25
   10    16    >   INIT_FCALL                                               'strtok'
         17        SEND_VAR                                                 !4
         18        SEND_VAL                                                 '-'
         19        DO_ICALL                                         $16     
         20        NOP                                                      
         21        FAST_CONCAT                                      ~17     '-', !3
         22        CONCAT                                           ~18     $16, ~17
         23        ASSIGN                                                   !4, ~18
    9    24      > JMP                                                      ->29
   12    25    >   UNSET_CV                                                 !4
   13    26        ASSIGN                                                   !4, !3
   14    27        FETCH_DIM_W                                      $21     !2
         28        ASSIGN_REF                                               $21, !4
   16    29    >   ASSIGN                                                   !5, !3
    8    30      > JMP                                                      ->7
         31    >   FE_FREE                                                  $10
   18    32        INIT_FCALL                                               'var_export'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.29 ms | 1009 KiB | 16 Q