3v4l.org

run code in 300+ 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 = 45
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 45
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 35
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
filename:       /in/Ar5ji
function name:  (null)
number of ops:  48
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, ->45
          3    > > FE_FETCH_R                                       ~10     $9, !2, ->45
          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        INIT_FCALL                                               'strpos'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                         $19     
         21        ASSIGN                                                   !6, $19
   11    22        TYPE_CHECK                                  1018          !6
         23      > JMPZ                                                     ~21, ->35
   12    24    >   INIT_FCALL                                               'substr_replace'
         25        SEND_VAR                                                 !1
         26        NOP                                                      
         27        FAST_CONCAT                                      ~22     '%2C+', !5
         28        SEND_VAL                                                 ~22
         29        SUB                                              ~23     !6, 1
         30        SEND_VAL                                                 ~23
         31        SEND_VAL                                                 0
         32        DO_ICALL                                         $24     
         33        ASSIGN                                                   !1, $24
   11    34      > JMP                                                      ->44
   14    35    > > JMPZ                                                     !1, ->38
         36    >   QM_ASSIGN                                        ~26     '+%26+'
         37      > JMP                                                      ->39
         38    >   QM_ASSIGN                                        ~26     ''
         39    >   ROPE_INIT                                     3  ~28     !5
         40        ROPE_ADD                                      1  ~28     ~28, '+'
         41        ROPE_END                                      2  ~27     ~28, !4
         42        CONCAT                                           ~30     ~26, ~27
         43        ASSIGN_OP                                     8          !1, ~30
    6    44    > > JMP                                                      ->3
         45    >   FE_FREE                                                  $9
   18    46        ECHO                                                     !1
   19    47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.44 ms | 1019 KiB | 15 Q