3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates = ['20240228', '20240229', '20240301']; function formatDates(array $datesInput) { foreach ($datesInput as $datesKey => $date) { $date = new DateTime($date); $month = $date->format('F'); $day = $date->format('j'); if ($datesKey == 0) { $datesOutput = $day; } elseif ($currentMonth <> $month) { $datesOutput .= " $currentMonth & $day"; } else { $datesOutput .= ", $day"; } $currentMonth = $month; } return "$datesOutput $month"; } echo formatDates($dates);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gUWih
function name:  (null)
number of ops:  6
compiled vars:  !0 = $dates
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'formatdates'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function formatdates:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 33
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 33
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
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 = 2
Branch analysis from position: 2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/gUWih
function name:  formatDates
number of ops:  39
compiled vars:  !0 = $datesInput, !1 = $date, !2 = $datesKey, !3 = $month, !4 = $day, !5 = $datesOutput, !6 = $currentMonth
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1      > FE_RESET_R                                       $7      !0, ->33
          2    > > FE_FETCH_R                                       ~8      $7, !1, ->33
          3    >   ASSIGN                                                   !2, ~8
    7     4        NEW                                              $10     'DateTime'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $10
    8     8        INIT_METHOD_CALL                                         !1, 'format'
          9        SEND_VAL_EX                                              'F'
         10        DO_FCALL                                      0  $13     
         11        ASSIGN                                                   !3, $13
    9    12        INIT_METHOD_CALL                                         !1, 'format'
         13        SEND_VAL_EX                                              'j'
         14        DO_FCALL                                      0  $15     
         15        ASSIGN                                                   !4, $15
   10    16        IS_EQUAL                                                 !2, 0
         17      > JMPZ                                                     ~17, ->20
   11    18    >   ASSIGN                                                   !5, !4
         19      > JMP                                                      ->31
   12    20    >   IS_NOT_EQUAL                                             !6, !3
         21      > JMPZ                                                     ~19, ->28
   13    22    >   ROPE_INIT                                     4  ~21     '+'
         23        ROPE_ADD                                      1  ~21     ~21, !6
         24        ROPE_ADD                                      2  ~21     ~21, '+%26+'
         25        ROPE_END                                      3  ~20     ~21, !4
         26        ASSIGN_OP                                     8          !5, ~20
         27      > JMP                                                      ->31
   15    28    >   NOP                                                      
         29        FAST_CONCAT                                      ~24     '%2C+', !4
         30        ASSIGN_OP                                     8          !5, ~24
   17    31    >   ASSIGN                                                   !6, !3
    6    32      > JMP                                                      ->2
         33    >   FE_FREE                                                  $7
   19    34        ROPE_INIT                                     3  ~28     !5
         35        ROPE_ADD                                      1  ~28     ~28, '+'
         36        ROPE_END                                      2  ~27     ~28, !3
         37      > RETURN                                                   ~27
   20    38*     > RETURN                                                   null

End of function formatdates

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.63 ms | 1407 KiB | 14 Q