3v4l.org

run code in 300+ PHP versions simultaneously
<?php function date_generator($ex_weeks = array(), $ex_DateTimeObjects = array()) { $kanji_w = array('日', '月', '火', '水', '木', '金', '土'); $now = new DateTime('now', new DateTimezon('Asia/Tokyo')); for ($i = 2; $i < 30; $i++) { $current = $now->add(new DateInterval("P{$i}D")); if (in_array($current->format('w'), $ex_weeks)) { continue; } foreach ($ex_DateTimeObjects as $object) { if (!$object->diff($current)->days) { continue 2; } } $w = $kanji_w[$current->format('w')]; yield $current->format('n月j日') . $w; } } ?> <select name="date"> <?php foreach (date_generator(array(1), array(new DateTime('12/25'))) as $value): ?> <option value="<?=$value?>"><?=$value?></option> <?php endforeach; ?> </select>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/LDinS
function name:  (null)
number of ops:  20
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ECHO                                                     '%3Cselect+name%3D%22date%22%3E%0A'
   23     1        INIT_FCALL                                               'date_generator'
          2        SEND_VAL                                                 <array>
          3        NEW                                              $1      'DateTime'
          4        SEND_VAL_EX                                              '12%2F25'
          5        DO_FCALL                                      0          
          6        INIT_ARRAY                                       ~3      $1
          7        SEND_VAL                                                 ~3
          8        DO_FCALL                                      0  $4      
          9      > FE_RESET_R                                       $5      $4, ->17
         10    > > FE_FETCH_R                                               $5, !0, ->17
   24    11    >   ECHO                                                     '%3Coption+value%3D%22'
         12        ECHO                                                     !0
         13        ECHO                                                     '%22%3E'
         14        ECHO                                                     !0
         15        ECHO                                                     '%3C%2Foption%3E%0A'
   23    16      > JMP                                                      ->10
         17    >   FE_FREE                                                  $5
   26    18        ECHO                                                     '%3C%2Fselect%3E'
         19      > RETURN                                                   1

Function date_generator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 14
Branch analysis from position: 58
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 14
Branch analysis from position: 58
Branch analysis from position: 14
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 44
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 44
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 14
Branch analysis from position: 58
Branch analysis from position: 14
Branch analysis from position: 44
filename:       /in/LDinS
function name:  date_generator
number of ops:  59
compiled vars:  !0 = $ex_weeks, !1 = $ex_DateTimeObjects, !2 = $kanji_w, !3 = $now, !4 = $i, !5 = $current, !6 = $object, !7 = $w
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      <array>
          1        RECV_INIT                                        !1      <array>
          2        GENERATOR_CREATE                                         
    4     3        ASSIGN                                                   !2, <array>
    5     4        NEW                                              $9      'DateTime'
          5        SEND_VAL_EX                                              'now'
          6        NEW                                              $10     'DateTimezon'
          7        SEND_VAL_EX                                              'Asia%2FTokyo'
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $10
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $9
    6    12        ASSIGN                                                   !4, 2
         13      > JMP                                                      ->56
    7    14    >   INIT_METHOD_CALL                                         !3, 'add'
         15        NEW                                              $15     'DateInterval'
         16        ROPE_INIT                                     3  ~17     'P'
         17        ROPE_ADD                                      1  ~17     ~17, !4
         18        ROPE_END                                      2  ~16     ~17, 'D'
         19        SEND_VAL_EX                                              ~16
         20        DO_FCALL                                      0          
         21        SEND_VAR_NO_REF_EX                                       $15
         22        DO_FCALL                                      0  $20     
         23        ASSIGN                                                   !5, $20
    8    24        INIT_FCALL                                               'in_array'
         25        INIT_METHOD_CALL                                         !5, 'format'
         26        SEND_VAL_EX                                              'w'
         27        DO_FCALL                                      0  $22     
         28        SEND_VAR                                                 $22
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $23     
         31      > JMPZ                                                     $23, ->33
    9    32    > > JMP                                                      ->55
   11    33    > > FE_RESET_R                                       $24     !1, ->44
         34    > > FE_FETCH_R                                               $24, !6, ->44
   12    35    >   INIT_METHOD_CALL                                         !6, 'diff'
         36        SEND_VAR_EX                                              !5
         37        DO_FCALL                                      0  $25     
         38        FETCH_OBJ_R                                      ~26     $25, 'days'
         39        BOOL_NOT                                         ~27     ~26
         40      > JMPZ                                                     ~27, ->43
   13    41    >   FE_FREE                                                  $24
         42      > JMP                                                      ->55
   11    43    > > JMP                                                      ->34
         44    >   FE_FREE                                                  $24
   16    45        INIT_METHOD_CALL                                         !5, 'format'
         46        SEND_VAL_EX                                              'w'
         47        DO_FCALL                                      0  $28     
         48        FETCH_DIM_R                                      ~29     !2, $28
         49        ASSIGN                                                   !7, ~29
   17    50        INIT_METHOD_CALL                                         !5, 'format'
         51        SEND_VAL_EX                                              'n%E6%9C%88j%E6%97%A5'
         52        DO_FCALL                                      0  $31     
         53        CONCAT                                           ~32     $31, !7
         54        YIELD                                                    ~32
    6    55    >   PRE_INC                                                  !4
         56    >   IS_SMALLER                                               !4, 30
         57      > JMPNZ                                                    ~35, ->14
   19    58    > > GENERATOR_RETURN                                         

End of function date_generator

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.13 ms | 1407 KiB | 16 Q