3v4l.org

run code in 300+ PHP versions simultaneously
<?php function time_elapsed_string($ptime) { $etime = time() - $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(3600);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fF7p5
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                                                 3600
          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 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 32
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 32
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 31
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/fF7p5
function name:  time_elapsed_string
number of ops:  34
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        INIT_FCALL                                               'time'
          2        DO_ICALL                                         $7      
          3        SUB                                              ~8      $7, !0
          4        ASSIGN                                                   !1, ~8
    7     5        IS_SMALLER                                               !1, 1
          6      > JMPZ                                                     ~10, ->8
    9     7    > > RETURN                                                   '0+seconds'
   12     8    >   ASSIGN                                                   !2, <array>
   20     9      > FE_RESET_R                                       $12     !2, ->32
         10    > > FE_FETCH_R                                       ~13     $12, !3, ->32
         11    >   ASSIGN                                                   !4, ~13
   22    12        DIV                                              ~15     !1, !4
         13        ASSIGN                                                   !5, ~15
   23    14        IS_SMALLER_OR_EQUAL                                      1, !5
         15      > JMPZ                                                     ~17, ->31
   25    16    >   INIT_FCALL                                               'round'
         17        SEND_VAR                                                 !5
         18        DO_ICALL                                         $18     
         19        ASSIGN                                                   !6, $18
   26    20        CONCAT                                           ~20     !6, '+'
         21        CONCAT                                           ~21     ~20, !3
         22        IS_SMALLER                                               1, !6
         23      > JMPZ                                                     ~22, ->26
         24    >   QM_ASSIGN                                        ~23     's'
         25      > JMP                                                      ->27
         26    >   QM_ASSIGN                                        ~23     ''
         27    >   CONCAT                                           ~24     ~21, ~23
         28        CONCAT                                           ~25     ~24, '+ago'
         29        FE_FREE                                                  $12
         30      > RETURN                                                   ~25
   20    31    > > JMP                                                      ->10
         32    >   FE_FREE                                                  $12
   29    33      > RETURN                                                   null

End of function time_elapsed_string

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.48 ms | 1407 KiB | 18 Q