3v4l.org

run code in 300+ PHP versions simultaneously
<?php function timeago($time) { $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade"); $lengths = array("60","60","24","7","4.35","12","10"); $now = time(); $difference = $now - $time; $tense = "ago"; for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { $difference /= $lengths[$j]; } $difference = round($difference); if($difference != 1) { $periods[$j].= "s"; } return "$difference $periods[$j] $tense"; } echo timeago('2013-03-03 09:52:05'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OXRW6
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'timeago'
          1        SEND_VAL                                                 '2013-03-03+09%3A52%3A05'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function timeago:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 11
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
Branch analysis from position: 21
Branch analysis from position: 21
filename:       /in/OXRW6
function name:  timeago
number of ops:  38
compiled vars:  !0 = $time, !1 = $periods, !2 = $lengths, !3 = $now, !4 = $difference, !5 = $tense, !6 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    7     3        INIT_FCALL                                               'time'
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !3, $9
    9     6        SUB                                              ~11     !3, !0
          7        ASSIGN                                                   !4, ~11
   10     8        ASSIGN                                                   !5, 'ago'
   12     9        ASSIGN                                                   !6, 0
         10      > JMP                                                      ->14
   14    11    >   FETCH_DIM_R                                      ~15     !2, !6
         12        ASSIGN_OP                                     4          !4, ~15
   12    13        PRE_INC                                                  !6
         14    >   FETCH_DIM_R                                      ~18     !2, !6
         15        IS_SMALLER_OR_EQUAL                              ~19     ~18, !4
         16      > JMPZ_EX                                          ~19     ~19, ->21
         17    >   COUNT                                            ~20     !2
         18        SUB                                              ~21     ~20, 1
         19        IS_SMALLER                                       ~22     !6, ~21
         20        BOOL                                             ~19     ~22
         21    > > JMPNZ                                                    ~19, ->11
   17    22    >   INIT_FCALL                                               'round'
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                         $23     
         25        ASSIGN                                                   !4, $23
   19    26        IS_NOT_EQUAL                                             !4, 1
         27      > JMPZ                                                     ~25, ->30
   21    28    >   ASSIGN_DIM_OP                .=               8          !1, !6
         29        OP_DATA                                                  's'
   24    30    >   ROPE_INIT                                     5  ~29     !4
         31        ROPE_ADD                                      1  ~29     ~29, '+'
         32        FETCH_DIM_R                                      ~27     !1, !6
         33        ROPE_ADD                                      2  ~29     ~29, ~27
         34        ROPE_ADD                                      3  ~29     ~29, '+'
         35        ROPE_END                                      4  ~28     ~29, !5
         36      > RETURN                                                   ~28
   25    37*     > RETURN                                                   null

End of function timeago

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.45 ms | 1403 KiB | 18 Q