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 $i => $month) { if ($i && $lookup[$month] === $lookup[$months[$i - 1]] + 1) { $ref = strtok($ref, "-") . "-$month"; } else { unset($ref); $ref = $month; $result[] = &$ref; } } 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 = 17
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 17
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/mnSou
function name:  (null)
number of ops:  37
compiled vars:  !0 = $lookup, !1 = $months, !2 = $result, !3 = $month, !4 = $i, !5 = $ref
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                                       ~11     $10, !3, ->32
          8    >   ASSIGN                                                   !4, ~11
    9     9      > JMPZ_EX                                          ~13     !4, ->17
         10    >   FETCH_DIM_R                                      ~14     !0, !3
         11        SUB                                              ~15     !4, 1
         12        FETCH_DIM_R                                      ~16     !1, ~15
         13        FETCH_DIM_R                                      ~17     !0, ~16
         14        ADD                                              ~18     ~17, 1
         15        IS_IDENTICAL                                     ~19     ~14, ~18
         16        BOOL                                             ~13     ~19
         17    > > JMPZ                                                     ~13, ->27
   10    18    >   INIT_FCALL                                               'strtok'
         19        SEND_VAR                                                 !5
         20        SEND_VAL                                                 '-'
         21        DO_ICALL                                         $20     
         22        NOP                                                      
         23        FAST_CONCAT                                      ~21     '-', !3
         24        CONCAT                                           ~22     $20, ~21
         25        ASSIGN                                                   !5, ~22
    9    26      > JMP                                                      ->31
   12    27    >   UNSET_CV                                                 !5
   13    28        ASSIGN                                                   !5, !3
   14    29        FETCH_DIM_W                                      $25     !2
         30        ASSIGN_REF                                               $25, !5
    8    31    > > JMP                                                      ->7
         32    >   FE_FREE                                                  $10
   17    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:
148.37 ms | 1012 KiB | 16 Q