3v4l.org

run code in 300+ PHP versions simultaneously
<?php function time_elapsed_string($ptime) { $etime = $ptime; if ($etime < 1) { return '0 seconds'; } $a = array( 12 * 30 * 24 * 60 * 60 => 'year', 30 * 24 * 60 * 60 => 'month', 24 * 60 * 60 => 'day', 60 * 60 => 'hour', 60 => 'minute', 1 => 'second' ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago'; } } } echo time_elapsed_string(70);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1KrSR
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'time_elapsed_string'
          1        SEND_VAL                                                 70
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function time_elapsed_string:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 28
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/1KrSR
function name:  time_elapsed_string
number of ops:  31
compiled vars:  !0 = $ptime, !1 = $etime, !2 = $a, !3 = $str, !4 = $secs, !5 = $d, !6 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, !0
    7     2        IS_SMALLER                                               !1, 1
          3      > JMPZ                                                     ~8, ->5
    9     4    > > RETURN                                                   '0+seconds'
   12     5    >   ASSIGN                                                   !2, <array>
   20     6      > FE_RESET_R                                       $10     !2, ->29
          7    > > FE_FETCH_R                                       ~11     $10, !3, ->29
          8    >   ASSIGN                                                   !4, ~11
   22     9        DIV                                              ~13     !1, !4
         10        ASSIGN                                                   !5, ~13
   23    11        IS_SMALLER_OR_EQUAL                                      1, !5
         12      > JMPZ                                                     ~15, ->28
   25    13    >   INIT_FCALL                                               'round'
         14        SEND_VAR                                                 !5
         15        DO_ICALL                                         $16     
         16        ASSIGN                                                   !6, $16
   26    17        CONCAT                                           ~18     !6, '+'
         18        CONCAT                                           ~19     ~18, !3
         19        IS_SMALLER                                               1, !6
         20      > JMPZ                                                     ~20, ->23
         21    >   QM_ASSIGN                                        ~21     's'
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~21     ''
         24    >   CONCAT                                           ~22     ~19, ~21
         25        CONCAT                                           ~23     ~22, '+ago'
         26        FE_FREE                                                  $10
         27      > RETURN                                                   ~23
   20    28    > > JMP                                                      ->7
         29    >   FE_FREE                                                  $10
   29    30      > RETURN                                                   null

End of function time_elapsed_string

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.04 ms | 1394 KiB | 16 Q