3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates = [ '2019-08-19 00:00:00', '2019-08-20 00:00:00', '2019-08-21 00:00:00', '2019-08-21 00:00:00', '2019-08-21 00:00:00', '2019-08-22 00:00:00', '2019-08-22 00:00:00', '2019-08-22 00:00:00', '2019-08-23 00:00:00', '2019-08-23 00:00:00', '2019-08-23 00:00:00', '2019-08-24 00:00:00', '2019-08-24 00:00:00', '2019-08-25 00:00:00', '2019-08-25 00:00:00', ]; $lastDay = ""; $i = -1; foreach ($dates as $date){ $i++; $dateTime = new DateTime($date); if ($lastDay != $dateTime->format("d") && $i != 0){ //$dates[$i - 1]['lastDay'] = true; echo ($i - 1) . " is a last row in a day\n"; } $lastDay = $dateTime->format("d"); } echo $i . " is a last row in a day\n";; // last row must be a last row in a day also
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 26
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 21
Branch analysis from position: 17
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/jc0BY
function name:  (null)
number of ops:  30
compiled vars:  !0 = $dates, !1 = $lastDay, !2 = $i, !3 = $date, !4 = $dateTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, ''
   22     2        ASSIGN                                                   !2, -1
   23     3      > FE_RESET_R                                       $8      !0, ->26
          4    > > FE_FETCH_R                                               $8, !3, ->26
   24     5    >   PRE_INC                                                  !2
   25     6        NEW                                              $10     'DateTime'
          7        SEND_VAR_EX                                              !3
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !4, $10
   26    10        INIT_METHOD_CALL                                         !4, 'format'
         11        SEND_VAL_EX                                              'd'
         12        DO_FCALL                                      0  $13     
         13        IS_NOT_EQUAL                                     ~14     !1, $13
         14      > JMPZ_EX                                          ~14     ~14, ->17
         15    >   IS_NOT_EQUAL                                     ~15     !2, 0
         16        BOOL                                             ~14     ~15
         17    > > JMPZ                                                     ~14, ->21
   28    18    >   SUB                                              ~16     !2, 1
         19        CONCAT                                           ~17     ~16, '+is+a+last+row+in+a+day%0A'
         20        ECHO                                                     ~17
   30    21    >   INIT_METHOD_CALL                                         !4, 'format'
         22        SEND_VAL_EX                                              'd'
         23        DO_FCALL                                      0  $18     
         24        ASSIGN                                                   !1, $18
   23    25      > JMP                                                      ->4
         26    >   FE_FREE                                                  $8
   33    27        CONCAT                                           ~20     !2, '+is+a+last+row+in+a+day%0A'
         28        ECHO                                                     ~20
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.85 ms | 1008 KiB | 13 Q