3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates_array = ['20241203', '20240115', '20240116', '20240228', '20240229', '20240301']; foreach ($dates_array as $date) { $datetimes[] = new DateTime($date); } foreach ($datetimes as $key=>$date) { $dateStr = $date->format('j'); //check if there's another entry after this one if (isset($datetimes[$key+1])) { //check the if following entry is in the same month and year as this one if ($datetimes[$key+1]->format("ym") == $date->format("ym")) { $dateStr .= ","; } else { $dateStr .= " ".$date->format("F")." & "; } } else { $dateStr .= " ".$date->format("F"); } $date_array[]= $dateStr; } $date_string = join( ' ', $date_array ) ; echo $date_string;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 47
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 47
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 39
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 9
filename:       /in/tWrhe
function name:  (null)
number of ops:  55
compiled vars:  !0 = $dates_array, !1 = $date, !2 = $datetimes, !3 = $key, !4 = $dateStr, !5 = $date_array, !6 = $date_string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1      > FE_RESET_R                                       $8      !0, ->9
          2    > > FE_FETCH_R                                               $8, !1, ->9
    7     3    >   NEW                                              $10     'DateTime'
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0          
          6        ASSIGN_DIM                                               !2
          7        OP_DATA                                                  $10
    5     8      > JMP                                                      ->2
          9    >   FE_FREE                                                  $8
   10    10      > FE_RESET_R                                       $12     !2, ->47
         11    > > FE_FETCH_R                                       ~13     $12, !1, ->47
         12    >   ASSIGN                                                   !3, ~13
   12    13        INIT_METHOD_CALL                                         !1, 'format'
         14        SEND_VAL_EX                                              'j'
         15        DO_FCALL                                      0  $15     
         16        ASSIGN                                                   !4, $15
   15    17        ADD                                              ~17     !3, 1
         18        ISSET_ISEMPTY_DIM_OBJ                         0          !2, ~17
         19      > JMPZ                                                     ~18, ->39
   18    20    >   ADD                                              ~19     !3, 1
         21        FETCH_DIM_R                                      ~20     !2, ~19
         22        INIT_METHOD_CALL                                         ~20, 'format'
         23        SEND_VAL_EX                                              'ym'
         24        DO_FCALL                                      0  $21     
         25        INIT_METHOD_CALL                                         !1, 'format'
         26        SEND_VAL_EX                                              'ym'
         27        DO_FCALL                                      0  $22     
         28        IS_EQUAL                                                 $21, $22
         29      > JMPZ                                                     ~23, ->32
   19    30    >   ASSIGN_OP                                     8          !4, '%2C'
   18    31      > JMP                                                      ->38
   23    32    >   INIT_METHOD_CALL                                         !1, 'format'
         33        SEND_VAL_EX                                              'F'
         34        DO_FCALL                                      0  $25     
         35        CONCAT                                           ~26     '+', $25
         36        CONCAT                                           ~27     ~26, '+%26+'
         37        ASSIGN_OP                                     8          !4, ~27
   15    38    > > JMP                                                      ->44
   27    39    >   INIT_METHOD_CALL                                         !1, 'format'
         40        SEND_VAL_EX                                              'F'
         41        DO_FCALL                                      0  $29     
         42        CONCAT                                           ~30     '+', $29
         43        ASSIGN_OP                                     8          !4, ~30
   30    44    >   ASSIGN_DIM                                               !5
         45        OP_DATA                                                  !4
   10    46      > JMP                                                      ->11
         47    >   FE_FREE                                                  $12
   33    48        INIT_FCALL                                               'join'
         49        SEND_VAL                                                 '+'
         50        SEND_VAR                                                 !5
         51        DO_ICALL                                         $33     
         52        ASSIGN                                                   !6, $33
   34    53        ECHO                                                     !6
   35    54      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.63 ms | 1018 KiB | 14 Q