3v4l.org

run code in 500+ PHP versions simultaneously
<?php $date = '10.11.2021 14:00'; $diff = (new DateTime($date))->diff(new DateTime()); $lookup = [ 'y' => 'year', 'm' => 'month', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', ]; $output = 'mere seconds'; foreach ($lookup as $property => $word) { if ($amt = $diff->$property) { if ($property === 'd' && $diff->$property >= 7) { $amt = intdiv($diff->$property, 7); $word = 'week'; } $output = "$amt $word" . ($amt !== 1 ? 's' : ''); break; } } echo "for $output";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 43
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 43
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 42
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
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 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 31
Branch analysis from position: 23
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 43
Branch analysis from position: 43
filename:       /in/v5NLm
function name:  (null)
number of ops:  48
compiled vars:  !0 = $date, !1 = $diff, !2 = $lookup, !3 = $output, !4 = $word, !5 = $property, !6 = $amt
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '10.11.2021+14%3A00'
    4     1        NEW                                                  $8      'DateTime'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        INIT_METHOD_CALL                                             $8, 'diff'
          5        NEW                                                  $10     'DateTime'
          6        DO_FCALL                                          0          
          7        SEND_VAR_NO_REF_EX                                           $10
          8        DO_FCALL                                          0  $12     
          9        ASSIGN                                                       !1, $12
    6    10        ASSIGN                                                       !2, <array>
   14    11        ASSIGN                                                       !3, 'mere+seconds'
   15    12      > FE_RESET_R                                           $16     !2, ->43
         13    > > FE_FETCH_R                                           ~17     $16, !4, ->43
         14    >   ASSIGN                                                       !5, ~17
   16    15        FETCH_OBJ_R                                          ~19     !1, !5
         16        ASSIGN                                               ~20     !6, ~19
         17      > JMPZ                                                         ~20, ->42
   17    18    >   IS_IDENTICAL                                         ~21     !5, 'd'
         19      > JMPZ_EX                                              ~21     ~21, ->23
         20    >   FETCH_OBJ_R                                          ~22     !1, !5
         21        IS_SMALLER_OR_EQUAL                                  ~23     7, ~22
         22        BOOL                                                 ~21     ~23
         23    > > JMPZ                                                         ~21, ->31
   18    24    >   INIT_FCALL                                                   'intdiv'
         25        FETCH_OBJ_R                                          ~24     !1, !5
         26        SEND_VAL                                                     ~24
         27        SEND_VAL                                                     7
         28        DO_ICALL                                             $25     
         29        ASSIGN                                                       !6, $25
   19    30        ASSIGN                                                       !4, 'week'
   21    31    >   ROPE_INIT                                         3  ~29     !6
         32        ROPE_ADD                                          1  ~29     ~29, '+'
         33        ROPE_END                                          2  ~28     ~29, !4
         34        IS_NOT_IDENTICAL                                             !6, 1
         35      > JMPZ                                                         ~31, ->38
         36    >   QM_ASSIGN                                            ~32     's'
         37      > JMP                                                          ->39
         38    >   QM_ASSIGN                                            ~32     ''
         39    >   CONCAT                                               ~33     ~28, ~32
         40        ASSIGN                                                       !3, ~33
   22    41      > JMP                                                          ->43
   15    42    > > JMP                                                          ->13
         43    >   FE_FREE                                                      $16
   25    44        NOP                                                          
         45        FAST_CONCAT                                          ~35     'for+', !3
         46        ECHO                                                         ~35
         47      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.51 ms | 1316 KiB | 14 Q