3v4l.org

run code in 500+ PHP versions simultaneously
<?php $time_array = ["17:45", "13:12", "09:29", "17:32", "16:49", "14:18"]; $buckets = array_fill_keys([-1, 0, 1], 0); // initialize buckets with 0 values foreach ($time_array as $time) { ++$buckets[(int)sqrt(substr($time, 0, 2) - 8) <=> 2]; } echo "Morning Count: {$buckets[-1]}\n"; // Hours: 00:00 to 11:59 ->12hrs (calculates as: 0, 1) echo "Afternoon Count: {$buckets[0]}\n"; // Hours: 12:00 to 16:59 -> 5hrs (calculates as: 2) echo "Evening Count: {$buckets[1]}"; // Hours: 17:00 to 23:59 -> 7hrs (calculates as: 3, 4) echo "\n---\n"; foreach (range(0, 23) as $t) { $calc = (float)sqrt($t - 8); echo "$t: " , (int)$calc , " ... [float value from sqrt was: $calc]\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 19
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 57
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 57
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Branch analysis from position: 19
filename:       /in/Jgp4Z
function name:  (null)
number of ops:  59
compiled vars:  !0 = $time_array, !1 = $buckets, !2 = $time, !3 = $t, !4 = $calc
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
    4     1        INIT_FCALL                                                   'array_fill_keys'
          2        SEND_VAL                                                     <array>
          3        SEND_VAL                                                     0
          4        DO_ICALL                                             $6      
          5        ASSIGN                                                       !1, $6
    6     6      > FE_RESET_R                                           $8      !0, ->19
          7    > > FE_FETCH_R                                                   $8, !2, ->19
    7     8    >   INIT_FCALL                                                   'sqrt'
          9        FRAMELESS_ICALL_3                substr              ~9      !2, 0
         10        OP_DATA                                                      2
         11        SUB                                                  ~10     ~9, 8
         12        SEND_VAL                                                     ~10
         13        DO_ICALL                                             $11     
         14        CAST                                              4  ~12     $11
         15        SPACESHIP                                            ~13     ~12, 2
         16        FETCH_DIM_RW                                         $14     !1, ~13
         17        PRE_INC                                                      $14
    6    18      > JMP                                                          ->7
         19    >   FE_FREE                                                      $8
   10    20        ROPE_INIT                                         3  ~18     'Morning+Count%3A+'
         21        FETCH_DIM_R                                          ~16     !1, -1
         22        ROPE_ADD                                          1  ~18     ~18, ~16
         23        ROPE_END                                          2  ~17     ~18, '%0A'
         24        ECHO                                                         ~17
   11    25        ROPE_INIT                                         3  ~22     'Afternoon+Count%3A+'
         26        FETCH_DIM_R                                          ~20     !1, 0
         27        ROPE_ADD                                          1  ~22     ~22, ~20
         28        ROPE_END                                          2  ~21     ~22, '%0A'
         29        ECHO                                                         ~21
   12    30        NOP                                                          
         31        FETCH_DIM_R                                          ~24     !1, 1
         32        FAST_CONCAT                                          ~25     'Evening+Count%3A+', ~24
         33        ECHO                                                         ~25
   14    34        ECHO                                                         '%0A---%0A'
   15    35        INIT_FCALL                                                   'range'
         36        SEND_VAL                                                     0
         37        SEND_VAL                                                     23
         38        DO_ICALL                                             $26     
         39      > FE_RESET_R                                           $27     $26, ->57
         40    > > FE_FETCH_R                                                   $27, !3, ->57
   16    41    >   INIT_FCALL                                                   'sqrt'
         42        SUB                                                  ~28     !3, 8
         43        SEND_VAL                                                     ~28
         44        DO_ICALL                                             $29     
         45        CAST                                              5  ~30     $29
         46        ASSIGN                                                       !4, ~30
   17    47        NOP                                                          
         48        FAST_CONCAT                                          ~32     !3, '%3A+'
         49        ECHO                                                         ~32
         50        CAST                                              4  ~33     !4
         51        ECHO                                                         ~33
         52        ROPE_INIT                                         3  ~35     '+...+%5Bfloat+value+from+sqrt+was%3A+'
         53        ROPE_ADD                                          1  ~35     ~35, !4
         54        ROPE_END                                          2  ~34     ~35, '%5D%0A'
         55        ECHO                                                         ~34
   15    56      > JMP                                                          ->40
         57    >   FE_FREE                                                      $27
   18    58      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.05 ms | 2355 KiB | 16 Q