3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{ "title":"event 1", "timeFrom":"2019-11-16 19:00:00", "timeTo":"2019-11-18 22:00:00", "listText":"text of the event", "url":"https://url", "imageUrl":"https://image.jpg", "locations":{ "title":"Location name", "url":"https://location" } }, { "title":"event 2", "timeFrom":"2019-11-20 19:00:00", "timeTo":"2019-11-20 22:00:00", "listText":"text of the event", "url":"https://url", "imageUrl":"https://image.jpg", "locations":{ "title":"Location name", "url":"https://location" } }, { "title":"event 3", "timeFrom":"2019-11-17 19:00:00", "timeTo":"2019-11-17 22:00:00", "listText":"text of the event", "url":"https://url", "imageUrl":"https://image.jpg", "locations":{ "title":"Location name", "url":"https://location" }}]'; function find_events($events, $date) { $date = new DateTime($date); foreach ($events as $event) { $from = (new DateTime($event['timeFrom']))->setTime(0,0,0); $to = (new DateTime($event['timeTo']))->setTime(0,0,0); if ($date >= $from && $date <= $to) { echo "{$event['title']} ({$event['listText']}) from {$event['timeFrom']} to {$event['timeTo']}\n"; } } } $events = json_decode($json, true); find_events($events, '2019-11-17');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qEh2r
function name:  (null)
number of ops:  11
compiled vars:  !0 = $json, !1 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B++%0A++++++%22title%22%3A%22event+1%22%2C%0A++++++%22timeFrom%22%3A%222019-11-16+19%3A00%3A00%22%2C%0A++++++%22timeTo%22%3A%222019-11-18+22%3A00%3A00%22%2C%0A++++++%22listText%22%3A%22text+of+the+event%22%2C%0A++++++%22url%22%3A%22https%3A%2F%2Furl%22%2C%0A++++++%22imageUrl%22%3A%22https%3A%2F%2Fimage.jpg%22%2C%0A++++++%22locations%22%3A%7B++%0A+++++++++%22title%22%3A%22Location+name%22%2C%0A+++++++++%22url%22%3A%22https%3A%2F%2Flocation%22%0A++++++%7D%0A+++%7D%2C%0A++++++%7B++%0A++++++%22title%22%3A%22event+2%22%2C%0A++++++%22timeFrom%22%3A%222019-11-20+19%3A00%3A00%22%2C%0A++++++%22timeTo%22%3A%222019-11-20+22%3A00%3A00%22%2C%0A++++++%22listText%22%3A%22text+of+the+event%22%2C%0A++++++%22url%22%3A%22https%3A%2F%2Furl%22%2C%0A++++++%22imageUrl%22%3A%22https%3A%2F%2Fimage.jpg%22%2C%0A++++++%22locations%22%3A%7B++%0A+++++++++%22title%22%3A%22Location+name%22%2C%0A+++++++++%22url%22%3A%22https%3A%2F%2Flocation%22%0A++++++%7D%0A+++%7D%2C%0A++++++%7B++%0A++++++%22title%22%3A%22event+3%22%2C%0A++++++%22timeFrom%22%3A%222019-11-17+19%3A00%3A00%22%2C%0A++++++%22timeTo%22%3A%222019-11-17+22%3A00%3A00%22%2C%0A++++++%22listText%22%3A%22text+of+the+event%22%2C%0A++++++%22url%22%3A%22https%3A%2F%2Furl%22%2C%0A++++++%22imageUrl%22%3A%22https%3A%2F%2Fimage.jpg%22%2C%0A++++++%22locations%22%3A%7B++%0A+++++++++%22title%22%3A%22Location+name%22%2C%0A+++++++++%22url%22%3A%22https%3A%2F%2Flocation%22%0A++++++%7D%7D%5D'
   49     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   50     6        INIT_FCALL                                               'find_events'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 '2019-11-17'
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

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

End of function find_events

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.85 ms | 1403 KiB | 16 Q