3v4l.org

run code in 300+ PHP versions simultaneously
<?php $diff = strtotime('2015-04-13T13:19:03+01:00')- strtotime('2015-04-14T10:55:28+01:00'); function secs_to_h($secs) { $units = array( "week" => 7*24*3600, "day" => 24*3600, "hour" => 3600, "minute" => 60, "second" => 1, ); // specifically handle zero if ( $secs == 0 ) return "0 seconds"; $s = ""; foreach ( $units as $name => $divisor ) { if ( $quot = intval($secs / $divisor) ) { $s .= "$quot $name"; $s .= (abs($quot) > 1 ? "s" : "") . ", "; $secs -= $quot * $divisor; } } return substr($s, 0, -2); } var_dump($diff, gmdate("m d H:i:s",$diff), secs_to_h($diff));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nPcbW
function name:  (null)
number of ops:  21
compiled vars:  !0 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'strtotime'
          1        SEND_VAL                                                 '2015-04-13T13%3A19%3A03%2B01%3A00'
          2        DO_ICALL                                         $1      
          3        INIT_FCALL                                               'strtotime'
          4        SEND_VAL                                                 '2015-04-14T10%3A55%3A28%2B01%3A00'
          5        DO_ICALL                                         $2      
          6        SUB                                              ~3      $1, $2
          7        ASSIGN                                                   !0, ~3
   30     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        INIT_FCALL                                               'gmdate'
         11        SEND_VAL                                                 'm+d+H%3Ai%3As'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $5      
         14        SEND_VAR                                                 $5
         15        INIT_FCALL                                               'secs_to_h'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0  $6      
         18        SEND_VAR                                                 $6
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function secs_to_h:
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 = 30
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 30
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 29
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/nPcbW
function name:  secs_to_h
number of ops:  38
compiled vars:  !0 = $secs, !1 = $units, !2 = $s, !3 = $divisor, !4 = $name, !5 = $quot
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, <array>
   15     2        IS_EQUAL                                                 !0, 0
          3      > JMPZ                                                     ~7, ->5
          4    > > RETURN                                                   '0+seconds'
   17     5    >   ASSIGN                                                   !2, ''
   19     6      > FE_RESET_R                                       $9      !1, ->30
          7    > > FE_FETCH_R                                       ~10     $9, !3, ->30
          8    >   ASSIGN                                                   !4, ~10
   20     9        DIV                                              ~12     !0, !3
         10        CAST                                          4  ~13     ~12
         11        ASSIGN                                           ~14     !5, ~13
         12      > JMPZ                                                     ~14, ->29
   21    13    >   ROPE_INIT                                     3  ~16     !5
         14        ROPE_ADD                                      1  ~16     ~16, '+'
         15        ROPE_END                                      2  ~15     ~16, !4
         16        ASSIGN_OP                                     8          !2, ~15
   22    17        INIT_FCALL                                               'abs'
         18        SEND_VAR                                                 !5
         19        DO_ICALL                                         $19     
         20        IS_SMALLER                                               1, $19
         21      > JMPZ                                                     ~20, ->24
         22    >   QM_ASSIGN                                        ~21     's'
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~21     ''
         25    >   CONCAT                                           ~22     ~21, '%2C+'
         26        ASSIGN_OP                                     8          !2, ~22
   23    27        MUL                                              ~24     !5, !3
         28        ASSIGN_OP                                     2          !0, ~24
   19    29    > > JMP                                                      ->7
         30    >   FE_FREE                                                  $9
   27    31        INIT_FCALL                                               'substr'
         32        SEND_VAR                                                 !2
         33        SEND_VAL                                                 0
         34        SEND_VAL                                                 -2
         35        DO_ICALL                                         $26     
         36      > RETURN                                                   $26
   28    37*     > RETURN                                                   null

End of function secs_to_h

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.83 ms | 1394 KiB | 24 Q