3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getHours($time) { return $time / 3600; } function getMinutes($time) { return $time / 60 % 60; } function getSeconds($time) { return $time % 60; } function statAssoc($strg) { $return = 'Range: %02d|%02d|%02d Average: %02d|%02d|%02d Median: %02d|%02d|%02d'; $results = array_map(function($result) { return explode('|', trim($result)); }, explode(',', $strg)); $sums = []; for ($i = 0; $i < count($results); $i++) { $sums[] = ($results[$i][0] * 60 * 60) + ($results[$i][1] * 60) + ($results[$i][2]); } $range = max($sums) - min($sums); $average = array_sum($sums) / count($results); $median = (count($results) % 2 !== 0) ? $sums[floor(count($sums) / 2)] + $sums[ceil(count($sums) / 2)] : $sums[ceil(count($sums) / 2)]; var_dump(count($results) % 2); return sprintf( $return, getHours($range), getMinutes($range), getSeconds($range), getHours($average), getMinutes($average), getSeconds($average), getHours($median), getMinutes($median), getSeconds($median) ); } echo statAssoc("01|15|59, 1|47|16, 01|17|20, 1|32|34, 2|17|17, 1|1|1");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IXITh
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   INIT_FCALL                                               'statassoc'
          1        SEND_VAL                                                 '01%7C15%7C59%2C+1%7C47%7C16%2C+01%7C17%7C20%2C+1%7C32%7C34%2C+2%7C17%7C17%2C+1%7C1%7C1'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function gethours:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IXITh
function name:  getHours
number of ops:  4
compiled vars:  !0 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        DIV                                              ~1      !0, 3600
          2      > RETURN                                                   ~1
    4     3*     > RETURN                                                   null

End of function gethours

Function getminutes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IXITh
function name:  getMinutes
number of ops:  5
compiled vars:  !0 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        DIV                                              ~1      !0, 60
          2        MOD                                              ~2      ~1, 60
          3      > RETURN                                                   ~2
    8     4*     > RETURN                                                   null

End of function getminutes

Function getseconds:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IXITh
function name:  getSeconds
number of ops:  4
compiled vars:  !0 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        MOD                                              ~1      !0, 60
          2      > RETURN                                                   ~1
   12     3*     > RETURN                                                   null

End of function getseconds

Function statassoc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 15
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 65
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 15
Branch analysis from position: 32
Branch analysis from position: 15
filename:       /in/IXITh
function name:  statAssoc
number of ops:  119
compiled vars:  !0 = $strg, !1 = $return, !2 = $results, !3 = $sums, !4 = $i, !5 = $range, !6 = $average, !7 = $median
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ASSIGN                                                   !1, 'Range%3A+%2502d%7C%2502d%7C%2502d+Average%3A+%2502d%7C%2502d%7C%2502d+Median%3A+%2502d%7C%2502d%7C%2502d'
   16     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FIXITh%3A16%240'
   18     4        SEND_VAL                                                 ~9
          5        INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '%2C'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $10     
          9        SEND_VAR                                                 $10
         10        DO_ICALL                                         $11     
   16    11        ASSIGN                                                   !2, $11
   21    12        ASSIGN                                                   !3, <array>
   22    13        ASSIGN                                                   !4, 0
         14      > JMP                                                      ->29
   23    15    >   FETCH_DIM_R                                      ~16     !2, !4
         16        FETCH_DIM_R                                      ~17     ~16, 0
         17        MUL                                              ~18     ~17, 60
         18        MUL                                              ~19     ~18, 60
         19        FETCH_DIM_R                                      ~20     !2, !4
         20        FETCH_DIM_R                                      ~21     ~20, 1
         21        MUL                                              ~22     ~21, 60
         22        ADD                                              ~23     ~19, ~22
         23        FETCH_DIM_R                                      ~24     !2, !4
         24        FETCH_DIM_R                                      ~25     ~24, 2
         25        ADD                                              ~26     ~23, ~25
         26        ASSIGN_DIM                                               !3
         27        OP_DATA                                                  ~26
   22    28        PRE_INC                                                  !4
         29    >   COUNT                                            ~28     !2
         30        IS_SMALLER                                               !4, ~28
         31      > JMPNZ                                                    ~29, ->15
   26    32    >   INIT_FCALL                                               'max'
         33        SEND_VAR                                                 !3
         34        DO_ICALL                                         $30     
         35        INIT_FCALL                                               'min'
         36        SEND_VAR                                                 !3
         37        DO_ICALL                                         $31     
         38        SUB                                              ~32     $30, $31
         39        ASSIGN                                                   !5, ~32
   27    40        INIT_FCALL                                               'array_sum'
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                         $34     
         43        COUNT                                            ~35     !2
         44        DIV                                              ~36     $34, ~35
         45        ASSIGN                                                   !6, ~36
   28    46        COUNT                                            ~38     !2
         47        MOD                                              ~39     ~38, 2
         48        IS_NOT_IDENTICAL                                         ~39, 0
         49      > JMPZ                                                     ~40, ->65
   29    50    >   INIT_FCALL                                               'floor'
         51        COUNT                                            ~41     !3
         52        DIV                                              ~42     ~41, 2
         53        SEND_VAL                                                 ~42
         54        DO_ICALL                                         $43     
         55        FETCH_DIM_R                                      ~44     !3, $43
         56        INIT_FCALL                                               'ceil'
         57        COUNT                                            ~45     !3
         58        DIV                                              ~46     ~45, 2
         59        SEND_VAL                                                 ~46
         60        DO_ICALL                                         $47     
         61        FETCH_DIM_R                                      ~48     !3, $47
         62        ADD                                              ~49     ~44, ~48
         63        QM_ASSIGN                                        ~50     ~49
         64      > JMP                                                      ->72
   30    65    >   INIT_FCALL                                               'ceil'
         66        COUNT                                            ~51     !3
         67        DIV                                              ~52     ~51, 2
         68        SEND_VAL                                                 ~52
         69        DO_ICALL                                         $53     
         70        FETCH_DIM_R                                      ~54     !3, $53
         71        QM_ASSIGN                                        ~50     ~54
   28    72    >   ASSIGN                                                   !7, ~50
   32    73        INIT_FCALL                                               'var_dump'
         74        COUNT                                            ~56     !2
         75        MOD                                              ~57     ~56, 2
         76        SEND_VAL                                                 ~57
         77        DO_ICALL                                                 
   33    78        INIT_FCALL                                               'sprintf'
   34    79        SEND_VAR                                                 !1
   35    80        INIT_FCALL                                               'gethours'
         81        SEND_VAR                                                 !5
         82        DO_FCALL                                      0  $59     
         83        SEND_VAR                                                 $59
   36    84        INIT_FCALL                                               'getminutes'
         85        SEND_VAR                                                 !5
         86        DO_FCALL                                      0  $60     
         87        SEND_VAR                                                 $60
   37    88        INIT_FCALL                                               'getseconds'
         89        SEND_VAR                                                 !5
         90        DO_FCALL                                      0  $61     
         91        SEND_VAR                                                 $61
   38    92        INIT_FCALL                                               'gethours'
         93        SEND_VAR                                                 !6
         94        DO_FCALL                                      0  $62     
         95        SEND_VAR                                                 $62
   39    96        INIT_FCALL                                               'getminutes'
         97        SEND_VAR                                                 !6
         98        DO_FCALL                                      0  $63     
         99        SEND_VAR                                                 $63
   40   100        INIT_FCALL                                               'getseconds'
        101        SEND_VAR                                                 !6
        102        DO_FCALL                                      0  $64     
        103        SEND_VAR                                                 $64
   41   104        INIT_FCALL                                               'gethours'
        105        SEND_VAR                                                 !7
        106        DO_FCALL                                      0  $65     
        107        SEND_VAR                                                 $65
   42   108        INIT_FCALL                                               'getminutes'
        109        SEND_VAR                                                 !7
        110        DO_FCALL                                      0  $66     
        111        SEND_VAR                                                 $66
   43   112        INIT_FCALL                                               'getseconds'
        113        SEND_VAR                                                 !7
        114        DO_FCALL                                      0  $67     
        115        SEND_VAR                                                 $67
        116        DO_ICALL                                         $68     
        117      > RETURN                                                   $68
   45   118*     > RETURN                                                   null

End of function statassoc

Function %00%7Bclosure%7D%2Fin%2FIXITh%3A16%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IXITh
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%7C'
          3        INIT_FCALL                                               'trim'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
   18     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FIXITh%3A16%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.3 ms | 1415 KiB | 43 Q