3v4l.org

run code in 500+ PHP versions simultaneously
<?php $json = '[ { "type":"playlist", "id": "35", "start_datetime": "2022-09-28 09:48", "end_datetime": "2022-09-28 09:51" }, { "type":"asset", "id": "4", "start_datetime": "2022-09-29 07:00", "end_datetime": "2022-09-29 07:30" }, { "type":"asset", "id": "4", "start_datetime": "2022-09-29 09:00", "end_datetime": "2022-09-29 09:30" } ]'; function find_events($events, $date) { $date = new DateTime($date); $r = ""; foreach ($events as $event) { $from = (new DateTime($event['start_datetime'])); $to = (new DateTime($event['end_datetime'])); if ($date >= $from && $date <= $to) { $r.= "{$event['start_datetime']} to {$event['end_datetime']}".'<br>'; } else{ $r.= "0<br>"; } } return $r; } $events = json_decode($json, true); print_r(find_events($events, '2022-09-29 07:00'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/30eIo
function name:  (null)
number of ops:  14
compiled vars:  !0 = $json, !1 = $events
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '%5B+%0A++%7B%0A+++++%22type%22%3A%22playlist%22%2C%0A+++++%22id%22%3A+%2235%22%2C%0A++++++%22start_datetime%22%3A+%222022-09-28+09%3A48%22%2C%0A++++++%22end_datetime%22%3A+%222022-09-28+09%3A51%22%0A++%7D%2C%0A++%7B%0A+++++%22type%22%3A%22asset%22%2C%0A+++++%22id%22%3A+%224%22%2C%0A++++++%22start_datetime%22%3A+%222022-09-29+07%3A00%22%2C%0A++++++%22end_datetime%22%3A+%222022-09-29+07%3A30%22%0A++%7D%2C%0A++%7B%0A+++++%22type%22%3A%22asset%22%2C%0A+++++%22id%22%3A+%224%22%2C%0A++++++%22start_datetime%22%3A+%222022-09-29+09%3A00%22%2C%0A++++++%22end_datetime%22%3A+%222022-09-29+09%3A30%22%0A++%7D%0A%5D'
   41     1        INIT_FCALL                                                   'json_decode'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     <true>
          4        DO_ICALL                                             $3      
          5        ASSIGN                                                       !1, $3
   42     6        INIT_FCALL                                                   'print_r'
          7        INIT_FCALL                                                   'find_events'
          8        SEND_VAR                                                     !1
          9        SEND_VAL                                                     '2022-09-29+07%3A00'
         10        DO_FCALL                                          0  $5      
         11        SEND_VAR                                                     $5
         12        DO_ICALL                                                     
         13      > RETURN                                                       1

Function find_events:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 36
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 36
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 34
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 25
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/30eIo
function name:  find_events
number of ops:  39
compiled vars:  !0 = $events, !1 = $date, !2 = $r, !3 = $event, !4 = $from, !5 = $to
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   24     2        NEW                                                  $6      'DateTime'
          3        SEND_VAR_EX                                                  !1
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !1, $6
   25     6        ASSIGN                                                       !2, ''
   27     7      > FE_RESET_R                                           $10     !0, ->36
          8    > > FE_FETCH_R                                                   $10, !3, ->36
   28     9    >   NEW                                                  $11     'DateTime'
         10        CHECK_FUNC_ARG                                               
         11        FETCH_DIM_FUNC_ARG                                   $12     !3, 'start_datetime'
         12        SEND_FUNC_ARG                                                $12
         13        DO_FCALL                                          0          
         14        ASSIGN                                                       !4, $11
   29    15        NEW                                                  $15     'DateTime'
         16        CHECK_FUNC_ARG                                               
         17        FETCH_DIM_FUNC_ARG                                   $16     !3, 'end_datetime'
         18        SEND_FUNC_ARG                                                $16
         19        DO_FCALL                                          0          
         20        ASSIGN                                                       !5, $15
   30    21        IS_SMALLER_OR_EQUAL                                  ~19     !4, !1
         22      > JMPZ_EX                                              ~19     ~19, ->25
         23    >   IS_SMALLER_OR_EQUAL                                  ~20     !1, !5
         24        BOOL                                                 ~19     ~20
         25    > > JMPZ                                                         ~19, ->34
   31    26    >   FETCH_DIM_R                                          ~21     !3, 'start_datetime'
         27        ROPE_INIT                                         3  ~24     ~21
         28        ROPE_ADD                                          1  ~24     ~24, '+to+'
         29        FETCH_DIM_R                                          ~22     !3, 'end_datetime'
         30        ROPE_END                                          2  ~23     ~24, ~22
         31        CONCAT                                               ~26     ~23, '%3Cbr%3E'
         32        ASSIGN_OP                                         8          !2, ~26
   30    33      > JMP                                                          ->35
   34    34    >   ASSIGN_OP                                         8          !2, '0%3Cbr%3E'
   27    35    > > JMP                                                          ->8
         36    >   FE_FREE                                                      $10
   38    37      > RETURN                                                       !2
   39    38*     > RETURN                                                       null

End of function find_events

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
173.16 ms | 1962 KiB | 16 Q