3v4l.org

run code in 500+ PHP versions simultaneously
<?php $dates = ['20240228', '20240229', '20240301']; $text = ''; foreach ($dates as $i => $date) { $date = new DateTime($date); $month = $date->format('F'); $day = $date->format('j'); $pos = strpos($text, $month); if ($pos !== false) { $text = substr_replace($text, ", $day", $pos - 1, 0); } else { $text .= ($text ? ' & ' : '') . "$day $month"; } } echo $text;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 42
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 42
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 32
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/Ar5ji
function name:  (null)
number of ops:  45
compiled vars:  !0 = $dates, !1 = $text, !2 = $date, !3 = $i, !4 = $month, !5 = $day, !6 = $pos
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    5     1        ASSIGN                                                       !1, ''
    6     2      > FE_RESET_R                                           $9      !0, ->42
          3    > > FE_FETCH_R                                           ~10     $9, !2, ->42
          4    >   ASSIGN                                                       !3, ~10
    7     5        NEW                                                  $12     'DateTime'
          6        SEND_VAR_EX                                                  !2
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !2, $12
    8     9        INIT_METHOD_CALL                                             !2, 'format'
         10        SEND_VAL_EX                                                  'F'
         11        DO_FCALL                                          0  $15     
         12        ASSIGN                                                       !4, $15
    9    13        INIT_METHOD_CALL                                             !2, 'format'
         14        SEND_VAL_EX                                                  'j'
         15        DO_FCALL                                          0  $17     
         16        ASSIGN                                                       !5, $17
   10    17        FRAMELESS_ICALL_2                strpos              ~19     !1, !4
         18        ASSIGN                                                       !6, ~19
   11    19        TYPE_CHECK                                      1018          !6
         20      > JMPZ                                                         ~21, ->32
   12    21    >   INIT_FCALL                                                   'substr_replace'
         22        SEND_VAR                                                     !1
         23        NOP                                                          
         24        FAST_CONCAT                                          ~22     '%2C+', !5
         25        SEND_VAL                                                     ~22
         26        SUB                                                  ~23     !6, 1
         27        SEND_VAL                                                     ~23
         28        SEND_VAL                                                     0
         29        DO_ICALL                                             $24     
         30        ASSIGN                                                       !1, $24
   11    31      > JMP                                                          ->41
   14    32    > > JMPZ                                                         !1, ->35
         33    >   QM_ASSIGN                                            ~26     '+%26+'
         34      > JMP                                                          ->36
         35    >   QM_ASSIGN                                            ~26     ''
         36    >   ROPE_INIT                                         3  ~28     !5
         37        ROPE_ADD                                          1  ~28     ~28, '+'
         38        ROPE_END                                          2  ~27     ~28, !4
         39        CONCAT                                               ~30     ~26, ~27
         40        ASSIGN_OP                                         8          !1, ~30
    6    41    > > JMP                                                          ->3
         42    >   FE_FREE                                                      $9
   18    43        ECHO                                                         !1
   19    44      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
154.99 ms | 1604 KiB | 14 Q