3v4l.org

run code in 500+ PHP versions simultaneously
<?php $now = time(); $yesterday = (new DateTime)->sub(new DateInterval('P1D')); $messages = [ // Yesteerday's messages [ 'user_id' => 1, 'user_natural_name' => 'me', 'timestamp' => $yesterday->setTime(19, 0)->format('U'), 'text' => 'Hiya' ], [ 'user_id' => 2, 'user_natural_name' => 'you', 'timestamp' => $yesterday->setTime(19, 5)->format('U'), 'text' => 'Hey, how are you?' ], // Today's messages [ 'user_id' => 1, 'user_natural_name' => 'me', 'timestamp' => $now, 'text' => 'Hello' ], [ 'user_id' => 2, 'user_natural_name' => 'you', 'timestamp' => $now + 3, 'text' => 'Hi' ], [ 'user_id' => 1, 'user_natural_name' => 'me', 'timestamp' => $now + 6, 'text' => 'What\'s up' ], [ 'user_id' => 2, 'user_natural_name' => 'you', 'timestamp' => $now + 9, 'text' => 'Not much' ], [ 'user_id' => 1, 'user_natural_name' => 'me', 'timestamp' => $now + 12, 'text' => 'Awesome' ] ]; $lastWindowDate = NULL; foreach ($messages as $index => $message) { $windowDate = date('Ymd', $message['timestamp']); if ($windowDate !== $lastWindowDate) { switch (date('Ymd', $message['timestamp'])) { case date('Ymd'): $dateLabel = 'today'; break; case $yesterday->format('Ymd'): $dateLabel = 'yesterday'; break; default: $dateLabel = $windowDate; break; } if ($index) echo "\n"; echo "$dateLabel\n"; $lastWindowDate = $windowDate; } echo "{$message['user_natural_name']}: " . date('H:i', $message['timestamp']) . " - {$message['text']}\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 68, Position 2 = 123
Branch analysis from position: 68
2 jumps found. (Code = 78) Position 1 = 69, Position 2 = 123
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 107
Branch analysis from position: 78
2 jumps found. (Code = 44) Position 1 = 88, Position 2 = 94
Branch analysis from position: 88
2 jumps found. (Code = 44) Position 1 = 93, Position 2 = 96
Branch analysis from position: 93
1 jumps found. (Code = 42) Position 1 = 98
Branch analysis from position: 98
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
2 jumps found. (Code = 43) Position 1 = 102, Position 2 = 103
Branch analysis from position: 102
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
Branch analysis from position: 103
Branch analysis from position: 96
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
Branch analysis from position: 94
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
Branch analysis from position: 107
Branch analysis from position: 123
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 123
filename:       /in/IGNhd
function name:  (null)
number of ops:  125
compiled vars:  !0 = $now, !1 = $yesterday, !2 = $messages, !3 = $lastWindowDate, !4 = $message, !5 = $index, !6 = $windowDate, !7 = $dateLabel
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'time'
          1        DO_ICALL                                             $8      
          2        ASSIGN                                                       !0, $8
    4     3        NEW                                                  $10     'DateTime'
          4        DO_FCALL                                          0          
          5        INIT_METHOD_CALL                                             $10, 'sub'
          6        NEW                                                  $12     'DateInterval'
          7        SEND_VAL_EX                                                  'P1D'
          8        DO_FCALL                                          0          
          9        SEND_VAR_NO_REF_EX                                           $12
         10        DO_FCALL                                          0  $14     
         11        ASSIGN                                                       !1, $14
    9    12        INIT_ARRAY                                           ~16     1, 'user_id'
   10    13        ADD_ARRAY_ELEMENT                                    ~16     'me', 'user_natural_name'
   11    14        INIT_METHOD_CALL                                             !1, 'setTime'
         15        SEND_VAL_EX                                                  19
         16        SEND_VAL_EX                                                  0
         17        DO_FCALL                                          0  $17     
         18        INIT_METHOD_CALL                                             $17, 'format'
         19        SEND_VAL_EX                                                  'U'
         20        DO_FCALL                                          0  $18     
         21        ADD_ARRAY_ELEMENT                                    ~16     $18, 'timestamp'
   12    22        ADD_ARRAY_ELEMENT                                    ~16     'Hiya', 'text'
         23        INIT_ARRAY                                           ~19     ~16
   15    24        INIT_ARRAY                                           ~20     2, 'user_id'
   16    25        ADD_ARRAY_ELEMENT                                    ~20     'you', 'user_natural_name'
   17    26        INIT_METHOD_CALL                                             !1, 'setTime'
         27        SEND_VAL_EX                                                  19
         28        SEND_VAL_EX                                                  5
         29        DO_FCALL                                          0  $21     
         30        INIT_METHOD_CALL                                             $21, 'format'
         31        SEND_VAL_EX                                                  'U'
         32        DO_FCALL                                          0  $22     
         33        ADD_ARRAY_ELEMENT                                    ~20     $22, 'timestamp'
   18    34        ADD_ARRAY_ELEMENT                                    ~20     'Hey%2C+how+are+you%3F', 'text'
         35        ADD_ARRAY_ELEMENT                                    ~19     ~20
   23    36        INIT_ARRAY                                           ~23     1, 'user_id'
   24    37        ADD_ARRAY_ELEMENT                                    ~23     'me', 'user_natural_name'
   25    38        ADD_ARRAY_ELEMENT                                    ~23     !0, 'timestamp'
   26    39        ADD_ARRAY_ELEMENT                                    ~23     'Hello', 'text'
         40        ADD_ARRAY_ELEMENT                                    ~19     ~23
   29    41        INIT_ARRAY                                           ~24     2, 'user_id'
   30    42        ADD_ARRAY_ELEMENT                                    ~24     'you', 'user_natural_name'
   31    43        ADD                                                  ~25     !0, 3
         44        ADD_ARRAY_ELEMENT                                    ~24     ~25, 'timestamp'
   32    45        ADD_ARRAY_ELEMENT                                    ~24     'Hi', 'text'
         46        ADD_ARRAY_ELEMENT                                    ~19     ~24
   35    47        INIT_ARRAY                                           ~26     1, 'user_id'
   36    48        ADD_ARRAY_ELEMENT                                    ~26     'me', 'user_natural_name'
   37    49        ADD                                                  ~27     !0, 6
         50        ADD_ARRAY_ELEMENT                                    ~26     ~27, 'timestamp'
   38    51        ADD_ARRAY_ELEMENT                                    ~26     'What%27s+up', 'text'
         52        ADD_ARRAY_ELEMENT                                    ~19     ~26
   41    53        INIT_ARRAY                                           ~28     2, 'user_id'
   42    54        ADD_ARRAY_ELEMENT                                    ~28     'you', 'user_natural_name'
   43    55        ADD                                                  ~29     !0, 9
         56        ADD_ARRAY_ELEMENT                                    ~28     ~29, 'timestamp'
   44    57        ADD_ARRAY_ELEMENT                                    ~28     'Not+much', 'text'
         58        ADD_ARRAY_ELEMENT                                    ~19     ~28
   47    59        INIT_ARRAY                                           ~30     1, 'user_id'
   48    60        ADD_ARRAY_ELEMENT                                    ~30     'me', 'user_natural_name'
   49    61        ADD                                                  ~31     !0, 12
         62        ADD_ARRAY_ELEMENT                                    ~30     ~31, 'timestamp'
   50    63        ADD_ARRAY_ELEMENT                                    ~30     'Awesome', 'text'
         64        ADD_ARRAY_ELEMENT                                    ~19     ~30
    5    65        ASSIGN                                                       !2, ~19
   54    66        ASSIGN                                                       !3, null
   55    67      > FE_RESET_R                                           $34     !2, ->123
         68    > > FE_FETCH_R                                           ~35     $34, !4, ->123
         69    >   ASSIGN                                                       !5, ~35
   57    70        INIT_FCALL                                                   'date'
         71        SEND_VAL                                                     'Ymd'
         72        FETCH_DIM_R                                          ~37     !4, 'timestamp'
         73        SEND_VAL                                                     ~37
         74        DO_ICALL                                             $38     
         75        ASSIGN                                                       !6, $38
   58    76        IS_NOT_IDENTICAL                                             !6, !3
         77      > JMPZ                                                         ~40, ->107
   60    78    >   INIT_FCALL                                                   'date'
         79        SEND_VAL                                                     'Ymd'
         80        FETCH_DIM_R                                          ~41     !4, 'timestamp'
         81        SEND_VAL                                                     ~41
         82        DO_ICALL                                             $42     
   62    83        INIT_FCALL                                                   'date'
         84        SEND_VAL                                                     'Ymd'
         85        DO_ICALL                                             $44     
         86        CASE                                                         $42, $44
         87      > JMPNZ                                                        ~43, ->94
   65    88    >   INIT_METHOD_CALL                                             !1, 'format'
         89        SEND_VAL_EX                                                  'Ymd'
         90        DO_FCALL                                          0  $45     
         91        CASE                                                         $42, $45
         92      > JMPNZ                                                        ~43, ->96
         93    > > JMP                                                          ->98
   63    94    >   ASSIGN                                                       !7, 'today'
   64    95      > JMP                                                          ->100
   66    96    >   ASSIGN                                                       !7, 'yesterday'
   67    97      > JMP                                                          ->100
   69    98    >   ASSIGN                                                       !7, !6
   70    99      > JMP                                                          ->100
        100    >   FREE                                                         $42
   73   101      > JMPZ                                                         !5, ->103
   74   102    >   ECHO                                                         '%0A'
   75   103    >   NOP                                                          
        104        FAST_CONCAT                                          ~49     !7, '%0A'
        105        ECHO                                                         ~49
   77   106        ASSIGN                                                       !3, !6
   80   107    >   FETCH_DIM_R                                          ~51     !4, 'user_natural_name'
        108        NOP                                                          
        109        FAST_CONCAT                                          ~52     ~51, '%3A+'
        110        INIT_FCALL                                                   'date'
        111        SEND_VAL                                                     'H%3Ai'
        112        FETCH_DIM_R                                          ~53     !4, 'timestamp'
        113        SEND_VAL                                                     ~53
        114        DO_ICALL                                             $54     
        115        CONCAT                                               ~55     ~52, $54
        116        ROPE_INIT                                         3  ~58     '+-+'
        117        FETCH_DIM_R                                          ~56     !4, 'text'
        118        ROPE_ADD                                          1  ~58     ~58, ~56
        119        ROPE_END                                          2  ~57     ~58, '%0A'
        120        CONCAT                                               ~60     ~55, ~57
        121        ECHO                                                         ~60
   55   122      > JMP                                                          ->68
        123    >   FE_FREE                                                      $34
   81   124      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.34 ms | 1655 KiB | 15 Q