3v4l.org

run code in 300+ PHP versions simultaneously
<?php function average_time($total, $count, $rounding = 0) { $total = explode(":", strval($total)); if (count($total) !== 3) return false; $sum = $total[0]*60*60 + $total[1]*60 + $total[2]; $average = $sum/(float)$count; $hours = floor($average/3600); $minutes = floor(fmod($average,3600)/60); $seconds = number_format(fmod(fmod($average,3600),60),(int)$rounding); return $hours.":".$minutes.":".$seconds; } echo average_time("190:24:00", 15);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vDor9
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'average_time'
          1        SEND_VAL                                                 '190%3A24%3A00'
          2        SEND_VAL                                                 15
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function average_time:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vDor9
function name:  average_time
number of ops:  59
compiled vars:  !0 = $total, !1 = $count, !2 = $rounding, !3 = $sum, !4 = $average, !5 = $hours, !6 = $minutes, !7 = $seconds
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
    3     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '%3A'
          5        CAST                                          6  ~8      !0
          6        SEND_VAL                                                 ~8
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !0, $9
    4     9        COUNT                                            ~11     !0
         10        IS_NOT_IDENTICAL                                         ~11, 3
         11      > JMPZ                                                     ~12, ->13
         12    > > RETURN                                                   <false>
    5    13    >   FETCH_DIM_R                                      ~13     !0, 0
         14        MUL                                              ~14     ~13, 60
         15        MUL                                              ~15     ~14, 60
         16        FETCH_DIM_R                                      ~16     !0, 1
         17        MUL                                              ~17     ~16, 60
         18        ADD                                              ~18     ~15, ~17
         19        FETCH_DIM_R                                      ~19     !0, 2
         20        ADD                                              ~20     ~18, ~19
         21        ASSIGN                                                   !3, ~20
    6    22        CAST                                          5  ~22     !1
         23        DIV                                              ~23     !3, ~22
         24        ASSIGN                                                   !4, ~23
    7    25        INIT_FCALL                                               'floor'
         26        DIV                                              ~25     !4, 3600
         27        SEND_VAL                                                 ~25
         28        DO_ICALL                                         $26     
         29        ASSIGN                                                   !5, $26
    8    30        INIT_FCALL                                               'floor'
         31        INIT_FCALL                                               'fmod'
         32        SEND_VAR                                                 !4
         33        SEND_VAL                                                 3600
         34        DO_ICALL                                         $28     
         35        DIV                                              ~29     $28, 60
         36        SEND_VAL                                                 ~29
         37        DO_ICALL                                         $30     
         38        ASSIGN                                                   !6, $30
    9    39        INIT_FCALL                                               'number_format'
         40        INIT_FCALL                                               'fmod'
         41        INIT_FCALL                                               'fmod'
         42        SEND_VAR                                                 !4
         43        SEND_VAL                                                 3600
         44        DO_ICALL                                         $32     
         45        SEND_VAR                                                 $32
         46        SEND_VAL                                                 60
         47        DO_ICALL                                         $33     
         48        SEND_VAR                                                 $33
         49        CAST                                          4  ~34     !2
         50        SEND_VAL                                                 ~34
         51        DO_ICALL                                         $35     
         52        ASSIGN                                                   !7, $35
   10    53        CONCAT                                           ~37     !5, '%3A'
         54        CONCAT                                           ~38     ~37, !6
         55        CONCAT                                           ~39     ~38, '%3A'
         56        CONCAT                                           ~40     ~39, !7
         57      > RETURN                                                   ~40
   11    58*     > RETURN                                                   null

End of function average_time

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.52 ms | 1394 KiB | 22 Q