3v4l.org

run code in 300+ PHP versions simultaneously
<?php $staff = array(1,2,3,4,5); $start = array("11:05", "11:00", "19:00", "13:00", "19:00"); $end = array("20:00", "17:00", "03:00", "20:00", "03:05"); array_multisort($start, $end, $staff); $aloneStart = (strtotime($start[1]) - strtotime($start[0]))/60; // first and second items are the ones that may be working alone at start $aloneEnd = (strtotime($end[count($end)-1]) - strtotime($end[count($end)-2]))/60; // last and second to last are the ones that may be working alone at end if($aloneStart > 0){ $staffAloneStart = $staff[0]; //must be the first who worked alone echo "minutes alone at start: " . $aloneStart . " and it was " . $staffAloneStart . "\n"; } if($aloneEnd > 0){ $staffAloneEnd = $staff[count($end)-1]; // must be the last to end that worked alone echo "minutes alone at end: " . $aloneEnd . " and it was " . $staffAloneEnd . "\n"; } $aloneTime = intval($aloneStart)+intval($aloneEnd); echo "total time alone " . $aloneTime;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 43
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 54
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 43
filename:       /in/6OmjO
function name:  (null)
number of ops:  61
compiled vars:  !0 = $staff, !1 = $start, !2 = $end, !3 = $aloneStart, !4 = $aloneEnd, !5 = $staffAloneStart, !6 = $staffAloneEnd, !7 = $aloneTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    7     3        INIT_FCALL                                               'array_multisort'
          4        SEND_REF                                                 !1
          5        SEND_REF                                                 !2
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
    9     8        INIT_FCALL                                               'strtotime'
          9        FETCH_DIM_R                                      ~12     !1, 1
         10        SEND_VAL                                                 ~12
         11        DO_ICALL                                         $13     
         12        INIT_FCALL                                               'strtotime'
         13        FETCH_DIM_R                                      ~14     !1, 0
         14        SEND_VAL                                                 ~14
         15        DO_ICALL                                         $15     
         16        SUB                                              ~16     $13, $15
         17        DIV                                              ~17     ~16, 60
         18        ASSIGN                                                   !3, ~17
   10    19        INIT_FCALL                                               'strtotime'
         20        COUNT                                            ~19     !2
         21        SUB                                              ~20     ~19, 1
         22        FETCH_DIM_R                                      ~21     !2, ~20
         23        SEND_VAL                                                 ~21
         24        DO_ICALL                                         $22     
         25        INIT_FCALL                                               'strtotime'
         26        COUNT                                            ~23     !2
         27        SUB                                              ~24     ~23, 2
         28        FETCH_DIM_R                                      ~25     !2, ~24
         29        SEND_VAL                                                 ~25
         30        DO_ICALL                                         $26     
         31        SUB                                              ~27     $22, $26
         32        DIV                                              ~28     ~27, 60
         33        ASSIGN                                                   !4, ~28
   11    34        IS_SMALLER                                               0, !3
         35      > JMPZ                                                     ~30, ->43
   12    36    >   FETCH_DIM_R                                      ~31     !0, 0
         37        ASSIGN                                                   !5, ~31
   13    38        CONCAT                                           ~33     'minutes+alone+at+start%3A+', !3
         39        CONCAT                                           ~34     ~33, '+and+it+was+'
         40        CONCAT                                           ~35     ~34, !5
         41        CONCAT                                           ~36     ~35, '%0A'
         42        ECHO                                                     ~36
   15    43    >   IS_SMALLER                                               0, !4
         44      > JMPZ                                                     ~37, ->54
   16    45    >   COUNT                                            ~38     !2
         46        SUB                                              ~39     ~38, 1
         47        FETCH_DIM_R                                      ~40     !0, ~39
         48        ASSIGN                                                   !6, ~40
   17    49        CONCAT                                           ~42     'minutes+alone+at+end%3A+', !4
         50        CONCAT                                           ~43     ~42, '+and+it+was+'
         51        CONCAT                                           ~44     ~43, !6
         52        CONCAT                                           ~45     ~44, '%0A'
         53        ECHO                                                     ~45
   19    54    >   CAST                                          4  ~46     !3
         55        CAST                                          4  ~47     !4
         56        ADD                                              ~48     ~46, ~47
         57        ASSIGN                                                   !7, ~48
   20    58        CONCAT                                           ~50     'total+time+alone+', !7
         59        ECHO                                                     ~50
         60      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.9 ms | 1004 KiB | 15 Q