3v4l.org

run code in 300+ PHP versions simultaneously
<?php $range = [ [ "min" => 321, "max" => 622, "name" => "wiosna" ], [ "min" => 622, "max" => 923, "name" => "lato" ], [ "min" => 923, "max" => 1222, "name" => "jesień" ] ]; $date = (int)date("md"); $style = "zima"; foreach($range as $season){ $numberGenerator = range($season["min"], $season["max"]); if( in_array($date, $numberGenerator) ){ $style = $season["name"]; } } var_dump($style); /* function testSeason(&$array, $date, $styleDefault= "zima"){ $style = $styleDefault; foreach($array as $season){ $numberGenerator = range($season["min"], $season["max"]); if( in_array($date, $numberGenerator) ){ $style = $season["name"]; } } return $style; } var_dump(testSeason($range, (int)date("md") )); var_dump(testSeason($range, 524 )); var_dump(testSeason($range, 813 )); var_dump(testSeason($range, 714 )); var_dump(testSeason($range, 1014 )); var_dump(testSeason($range, 1214 )); var_dump(testSeason($range, 1227 )); var_dump(testSeason($range, 101 )); var_dump(testSeason($range, 303 )); */
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/HNq5E
function name:  (null)
number of ops:  29
compiled vars:  !0 = $range, !1 = $date, !2 = $style, !3 = $season, !4 = $numberGenerator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'md'
          3        DO_ICALL                                         $6      
          4        CAST                                          4  ~7      $6
          5        ASSIGN                                                   !1, ~7
   21     6        ASSIGN                                                   !2, 'zima'
   22     7      > FE_RESET_R                                       $10     !0, ->24
          8    > > FE_FETCH_R                                               $10, !3, ->24
   23     9    >   INIT_FCALL                                               'range'
         10        FETCH_DIM_R                                      ~11     !3, 'min'
         11        SEND_VAL                                                 ~11
         12        FETCH_DIM_R                                      ~12     !3, 'max'
         13        SEND_VAL                                                 ~12
         14        DO_ICALL                                         $13     
         15        ASSIGN                                                   !4, $13
   24    16        INIT_FCALL                                               'in_array'
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                         $15     
         20      > JMPZ                                                     $15, ->23
   25    21    >   FETCH_DIM_R                                      ~16     !3, 'name'
         22        ASSIGN                                                   !2, ~16
   22    23    > > JMP                                                      ->8
         24    >   FE_FREE                                                  $10
   29    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                                 
   52    28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.06 ms | 1396 KiB | 21 Q