3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('UTC'); $currentDateTime = new DateTime(); $url = 'https://www.lmsal.com/hek/hcr?cmd=view-planned-events&instrument=iris'; $content = file_get_contents($url); $dom = new DOMDocument(); @$dom->loadHTML($content); $table = $dom->getElementsByTagName('table')->item(0); $rows = $table->getElementsByTagName('tr'); foreach($rows as $row) { $columns = $row->getElementsByTagName('td'); if ($columns->length > 0) { $dateTimeRange = $columns->item(0)->nodeValue; // Match the pattern "YYYY-MM-DD HH:MM:SS - HH:MM:SS" and store the matches in $matches array preg_match_all('/\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}-\d{2}:\d{2}:\d{2}/', $dateTimeRange, $matches); foreach ($matches[0] as $match) { list($start, $end) = explode("-", $match); $startDateTime = DateTime::createFromFormat('Y-m-d H:i:s', trim($start)); $endDateTime = DateTime::createFromFormat('Y-m-d H:i:s', trim($end)); // If the current time is within the start and end times, print it out if ($startDateTime <= $currentDateTime && $currentDateTime <= $endDateTime) { echo $match . '<br>'; } } } } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 87
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 87
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 86
Branch analysis from position: 39
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 85
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 85
Branch analysis from position: 52
2 jumps found. (Code = 46) Position 1 = 79, Position 2 = 81
Branch analysis from position: 79
2 jumps found. (Code = 43) Position 1 = 82, Position 2 = 84
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 84
Branch analysis from position: 81
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 85
Branch analysis from position: 86
Branch analysis from position: 87
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 87
filename:       /in/kXYqA
function name:  (null)
number of ops:  89
compiled vars:  !0 = $currentDateTime, !1 = $url, !2 = $content, !3 = $dom, !4 = $table, !5 = $rows, !6 = $row, !7 = $columns, !8 = $dateTimeRange, !9 = $matches, !10 = $match, !11 = $start, !12 = $end, !13 = $startDateTime, !14 = $endDateTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'UTC'
          2        DO_ICALL                                                 
    3     3        NEW                                              $16     'DateTime'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $16
    5     6        ASSIGN                                                   !1, 'https%3A%2F%2Fwww.lmsal.com%2Fhek%2Fhcr%3Fcmd%3Dview-planned-events%26instrument%3Diris'
    6     7        INIT_FCALL                                               'file_get_contents'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $20     
         10        ASSIGN                                                   !2, $20
    8    11        NEW                                              $22     'DOMDocument'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !3, $22
    9    14        BEGIN_SILENCE                                    ~25     
         15        INIT_METHOD_CALL                                         !3, 'loadHTML'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0          
         18        END_SILENCE                                              ~25
   11    19        INIT_METHOD_CALL                                         !3, 'getElementsByTagName'
         20        SEND_VAL_EX                                              'table'
         21        DO_FCALL                                      0  $27     
         22        INIT_METHOD_CALL                                         $27, 'item'
         23        SEND_VAL_EX                                              0
         24        DO_FCALL                                      0  $28     
         25        ASSIGN                                                   !4, $28
   12    26        INIT_METHOD_CALL                                         !4, 'getElementsByTagName'
         27        SEND_VAL_EX                                              'tr'
         28        DO_FCALL                                      0  $30     
         29        ASSIGN                                                   !5, $30
   14    30      > FE_RESET_R                                       $32     !5, ->87
         31    > > FE_FETCH_R                                               $32, !6, ->87
   15    32    >   INIT_METHOD_CALL                                         !6, 'getElementsByTagName'
         33        SEND_VAL_EX                                              'td'
         34        DO_FCALL                                      0  $33     
         35        ASSIGN                                                   !7, $33
   17    36        FETCH_OBJ_R                                      ~35     !7, 'length'
         37        IS_SMALLER                                               0, ~35
         38      > JMPZ                                                     ~36, ->86
   18    39    >   INIT_METHOD_CALL                                         !7, 'item'
         40        SEND_VAL_EX                                              0
         41        DO_FCALL                                      0  $37     
         42        FETCH_OBJ_R                                      ~38     $37, 'nodeValue'
         43        ASSIGN                                                   !8, ~38
   21    44        INIT_FCALL                                               'preg_match_all'
         45        SEND_VAL                                                 '%2F%5Cd%7B4%7D-%5Cd%7B2%7D-%5Cd%7B2%7D%5Cs%5Cd%7B2%7D%3A%5Cd%7B2%7D%3A%5Cd%7B2%7D-%5Cd%7B2%7D%3A%5Cd%7B2%7D%3A%5Cd%7B2%7D%2F'
         46        SEND_VAR                                                 !8
         47        SEND_REF                                                 !9
         48        DO_ICALL                                                 
   23    49        FETCH_DIM_R                                      ~41     !9, 0
         50      > FE_RESET_R                                       $42     ~41, ->85
         51    > > FE_FETCH_R                                               $42, !10, ->85
   24    52    >   INIT_FCALL                                               'explode'
         53        SEND_VAL                                                 '-'
         54        SEND_VAR                                                 !10
         55        DO_ICALL                                         $43     
         56        FETCH_LIST_R                                     $44     $43, 0
         57        ASSIGN                                                   !11, $44
         58        FETCH_LIST_R                                     $46     $43, 1
         59        ASSIGN                                                   !12, $46
         60        FREE                                                     $43
   25    61        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         62        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         63        INIT_FCALL                                               'trim'
         64        SEND_VAR                                                 !11
         65        DO_ICALL                                         $48     
         66        SEND_VAR                                                 $48
         67        DO_FCALL                                      0  $49     
         68        ASSIGN                                                   !13, $49
   26    69        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         70        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         71        INIT_FCALL                                               'trim'
         72        SEND_VAR                                                 !12
         73        DO_ICALL                                         $51     
         74        SEND_VAR                                                 $51
         75        DO_FCALL                                      0  $52     
         76        ASSIGN                                                   !14, $52
   29    77        IS_SMALLER_OR_EQUAL                              ~54     !13, !0
         78      > JMPZ_EX                                          ~54     ~54, ->81
         79    >   IS_SMALLER_OR_EQUAL                              ~55     !0, !14
         80        BOOL                                             ~54     ~55
         81    > > JMPZ                                                     ~54, ->84
   30    82    >   CONCAT                                           ~56     !10, '%3Cbr%3E'
         83        ECHO                                                     ~56
   23    84    > > JMP                                                      ->51
         85    >   FE_FREE                                                  $42
   14    86    > > JMP                                                      ->31
         87    >   FE_FREE                                                  $32
   35    88      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.11 ms | 1404 KiB | 23 Q