3v4l.org

run code in 300+ PHP versions simultaneously
<?php function secondsToString($seconds) { $units = ['day' => 86400, 'hour' => 3600, 'minute' => 60, 'second' => 1]; $parts = []; foreach ($units as $name => $duration) { $div = floor($seconds / $duration); if ($div == 0) { continue; } $parts[] = $div == 1 ? "{$div} {$name}" : "{$div} {$name}s"; $seconds %= $duration; } $last = array_pop($parts); return empty($parts) ? $last : join(', ', $parts) . " and " . $last; } echo secondsToString(245);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kLnV3
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'secondstostring'
          1        SEND_VAL                                                 245
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function secondstostring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 30
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/kLnV3
function name:  secondsToString
number of ops:  48
compiled vars:  !0 = $seconds, !1 = $units, !2 = $parts, !3 = $duration, !4 = $name, !5 = $div, !6 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    7     3      > FE_RESET_R                                       $9      !1, ->30
          4    > > FE_FETCH_R                                       ~10     $9, !3, ->30
          5    >   ASSIGN                                                   !4, ~10
    8     6        INIT_FCALL                                               'floor'
          7        DIV                                              ~12     !0, !3
          8        SEND_VAL                                                 ~12
          9        DO_ICALL                                         $13     
         10        ASSIGN                                                   !5, $13
   10    11        IS_EQUAL                                                 !5, 0
         12      > JMPZ                                                     ~15, ->14
   11    13    > > JMP                                                      ->4
   14    14    >   IS_EQUAL                                                 !5, 1
         15      > JMPZ                                                     ~17, ->21
         16    >   ROPE_INIT                                     3  ~19     !5
         17        ROPE_ADD                                      1  ~19     ~19, '+'
         18        ROPE_END                                      2  ~18     ~19, !4
         19        QM_ASSIGN                                        ~21     ~18
         20      > JMP                                                      ->26
         21    >   ROPE_INIT                                     4  ~23     !5
         22        ROPE_ADD                                      1  ~23     ~23, '+'
         23        ROPE_ADD                                      2  ~23     ~23, !4
         24        ROPE_END                                      3  ~22     ~23, 's'
         25        QM_ASSIGN                                        ~21     ~22
         26    >   ASSIGN_DIM                                               !2
         27        OP_DATA                                                  ~21
   15    28        ASSIGN_OP                                     5          !0, !3
    7    29      > JMP                                                      ->4
         30    >   FE_FREE                                                  $9
   18    31        INIT_FCALL                                               'array_pop'
         32        SEND_REF                                                 !2
         33        DO_ICALL                                         $26     
         34        ASSIGN                                                   !6, $26
   20    35        ISSET_ISEMPTY_CV                                         !2
         36      > JMPZ                                                     ~28, ->39
         37    >   QM_ASSIGN                                        ~29     !6
         38      > JMP                                                      ->46
         39    >   INIT_FCALL                                               'join'
         40        SEND_VAL                                                 '%2C+'
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                         $30     
         43        CONCAT                                           ~31     $30, '+and+'
         44        CONCAT                                           ~32     ~31, !6
         45        QM_ASSIGN                                        ~29     ~32
         46    > > RETURN                                                   ~29
   21    47*     > RETURN                                                   null

End of function secondstostring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.94 ms | 1403 KiB | 20 Q