3v4l.org

run code in 500+ PHP versions simultaneously
<?php $times = ['17:45', '13:12', '09:29', '17:32', '16:49', '14:18']; $counts = array_reduce($times, function($counts, $time) { $hour = (int)substr($time, 0, 2); $moment = in_array($hour, range(9, 12)) ? 'morning' : (in_array($hour, range(13, 16)) ? 'afternoon' : 'evening'); $counts[$moment]++; return $counts; }, ['morning' => 0, 'afternoon' => 0, 'evening' => 0]); echo '<pre>'; var_dump($counts); echo '</pre>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D7c9f
function name:  (null)
number of ops:  14
compiled vars:  !0 = $times, !1 = $counts
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
    4     1        INIT_FCALL                                                   'array_reduce'
          2        SEND_VAR                                                     !0
          3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
    9     4        SEND_VAL                                                     ~3
          5        SEND_VAL                                                     <array>
    4     6        DO_ICALL                                             $4      
          7        ASSIGN                                                       !1, $4
   11     8        ECHO                                                         '%3Cpre%3E'
          9        INIT_FCALL                                                   'var_dump'
         10        SEND_VAR                                                     !1
         11        DO_ICALL                                                     
         12        ECHO                                                         '%3C%2Fpre%3E'
         13      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D7c9f
function name:  {closure:/in/D7c9f:4}
number of ops:  29
compiled vars:  !0 = $counts, !1 = $time, !2 = $hour, !3 = $moment
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        FRAMELESS_ICALL_3                substr              ~4      !1, 0
          3        OP_DATA                                                      2
          4        CAST                                              4  ~5      ~4
          5        ASSIGN                                                       !2, ~5
    6     6        INIT_FCALL                                                   'range'
          7        SEND_VAL                                                     9
          8        SEND_VAL                                                     12
          9        DO_ICALL                                             $7      
         10        FRAMELESS_ICALL_2                in_array            ~8      !2, $7
         11      > JMPZ                                                         ~8, ->14
         12    >   QM_ASSIGN                                            ~9      'morning'
         13      > JMP                                                          ->24
         14    >   INIT_FCALL                                                   'range'
         15        SEND_VAL                                                     13
         16        SEND_VAL                                                     16
         17        DO_ICALL                                             $10     
         18        FRAMELESS_ICALL_2                in_array            ~11     !2, $10
         19      > JMPZ                                                         ~11, ->22
         20    >   QM_ASSIGN                                            ~12     'afternoon'
         21      > JMP                                                          ->23
         22    >   QM_ASSIGN                                            ~12     'evening'
         23    >   QM_ASSIGN                                            ~9      ~12
         24    >   ASSIGN                                                       !3, ~9
    7    25        FETCH_DIM_RW                                         $14     !0, !3
         26        PRE_INC                                                      $14
    8    27      > RETURN                                                       !0
    9    28*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.45 ms | 2273 KiB | 16 Q