3v4l.org

run code in 300+ 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 = 22
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 22
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 60
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 60
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
Branch analysis from position: 22
filename:       /in/Jgp4Z
function name:  (null)
number of ops:  62
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, ->22
          7    > > FE_FETCH_R                                               $8, !2, ->22
    7     8    >   INIT_FCALL                                               'sqrt'
          9        INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !2
         11        SEND_VAL                                                 0
         12        SEND_VAL                                                 2
         13        DO_ICALL                                         $9      
         14        SUB                                              ~10     $9, 8
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                         $11     
         17        CAST                                          4  ~12     $11
         18        SPACESHIP                                        ~13     ~12, 2
         19        FETCH_DIM_RW                                     $14     !1, ~13
         20        PRE_INC                                                  $14
    6    21      > JMP                                                      ->7
         22    >   FE_FREE                                                  $8
   10    23        ROPE_INIT                                     3  ~18     'Morning+Count%3A+'
         24        FETCH_DIM_R                                      ~16     !1, -1
         25        ROPE_ADD                                      1  ~18     ~18, ~16
         26        ROPE_END                                      2  ~17     ~18, '%0A'
         27        ECHO                                                     ~17
   11    28        ROPE_INIT                                     3  ~22     'Afternoon+Count%3A+'
         29        FETCH_DIM_R                                      ~20     !1, 0
         30        ROPE_ADD                                      1  ~22     ~22, ~20
         31        ROPE_END                                      2  ~21     ~22, '%0A'
         32        ECHO                                                     ~21
   12    33        NOP                                                      
         34        FETCH_DIM_R                                      ~24     !1, 1
         35        FAST_CONCAT                                      ~25     'Evening+Count%3A+', ~24
         36        ECHO                                                     ~25
   14    37        ECHO                                                     '%0A---%0A'
   15    38        INIT_FCALL                                               'range'
         39        SEND_VAL                                                 0
         40        SEND_VAL                                                 23
         41        DO_ICALL                                         $26     
         42      > FE_RESET_R                                       $27     $26, ->60
         43    > > FE_FETCH_R                                               $27, !3, ->60
   16    44    >   INIT_FCALL                                               'sqrt'
         45        SUB                                              ~28     !3, 8
         46        SEND_VAL                                                 ~28
         47        DO_ICALL                                         $29     
         48        CAST                                          5  ~30     $29
         49        ASSIGN                                                   !4, ~30
   17    50        NOP                                                      
         51        FAST_CONCAT                                      ~32     !3, '%3A+'
         52        ECHO                                                     ~32
         53        CAST                                          4  ~33     !4
         54        ECHO                                                     ~33
         55        ROPE_INIT                                     3  ~35     '+...+%5Bfloat+value+from+sqrt+was%3A+'
         56        ROPE_ADD                                      1  ~35     ~35, !4
         57        ROPE_END                                      2  ~34     ~35, '%5D%0A'
         58        ECHO                                                     ~34
   15    59      > JMP                                                      ->43
         60    >   FE_FREE                                                  $27
   18    61      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.06 ms | 1008 KiB | 17 Q