3v4l.org

run code in 300+ PHP versions simultaneously
<?php function japan_holiday_ics() { // カレンダーID $calendar_id = urlencode('japanese__ja@holiday.calendar.google.com'); $url = 'https://calendar.google.com/calendar/ical/'.$calendar_id.'/public/full.ics'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch); if (!empty($result)) { $items = $sort = array(); $start = false; $count = 0; foreach(explode("\n", $result) as $row => $line) { // 1行目が「BEGIN:VCALENDAR」でなければ終了 if (0 === $row && false === stristr($line, 'BEGIN:VCALENDAR')) { break; } // 改行などを削除 $line = trim($line); // 「BEGIN:VEVENT」なら日付データの開始 if (false !== stristr($line, 'BEGIN:VEVENT')) { $start = true; } elseif ($start) { // 「END:VEVENT」なら日付データの終了 if (false !== stristr($line, 'END:VEVENT')) { $start = false; // 次のデータ用にカウントを追加 ++$count; } else { // 配列がなければ作成 if (empty($items[$count])) { $items[$count] = array('date' => null, 'title' => null); } // 「DTSTART;~」(対象日)の処理 if(0 === strpos($line, 'DTSTART;VALUE')) { $date = explode(':', $line); $date = end($date); $items[$count]['date'] = $date; // ソート用の配列にセット $sort[$count] = $date; } // 「SUMMARY:~」(名称)の処理 elseif(0 === strpos($line, 'SUMMARY:')) { list($title) = explode('/', substr($line, 8)); $items[$count]['title'] = trim($title); } } } } // 日付でソート $items = array_combine($sort, $items); ksort($items); return $items; } } japan_holiday_ics();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UCBho
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   INIT_FCALL                                               'japan_holiday_ics'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Function japan_holiday_ics:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 146
Branch analysis from position: 44
2 jumps found. (Code = 77) Position 1 = 53, Position 2 = 136
Branch analysis from position: 53
2 jumps found. (Code = 78) Position 1 = 54, Position 2 = 136
Branch analysis from position: 54
2 jumps found. (Code = 46) Position 1 = 57, Position 2 = 63
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 65
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 136
Branch analysis from position: 136
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 77
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 135
Branch analysis from position: 135
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 135
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 87
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 135
Branch analysis from position: 135
Branch analysis from position: 87
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 91
Branch analysis from position: 89
2 jumps found. (Code = 43) Position 1 = 97, Position 2 = 112
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 135
Branch analysis from position: 135
Branch analysis from position: 112
2 jumps found. (Code = 43) Position 1 = 118, Position 2 = 135
Branch analysis from position: 118
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 135
Branch analysis from position: 91
Branch analysis from position: 135
Branch analysis from position: 63
Branch analysis from position: 136
Branch analysis from position: 136
Branch analysis from position: 146
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UCBho
function name:  japan_holiday_ics
number of ops:  147
compiled vars:  !0 = $calendar_id, !1 = $url, !2 = $ch, !3 = $result, !4 = $items, !5 = $sort, !6 = $start, !7 = $count, !8 = $line, !9 = $row, !10 = $date, !11 = $title
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'urlencode'
          1        SEND_VAL                                                 'japanese__ja%40holiday.calendar.google.com'
          2        DO_ICALL                                         $12     
          3        ASSIGN                                                   !0, $12
    6     4        CONCAT                                           ~14     'https%3A%2F%2Fcalendar.google.com%2Fcalendar%2Fical%2F', !0
          5        CONCAT                                           ~15     ~14, '%2Fpublic%2Ffull.ics'
          6        ASSIGN                                                   !1, ~15
    7     7        INIT_FCALL_BY_NAME                                       'curl_init'
          8        DO_FCALL                                      0  $17     
          9        ASSIGN                                                   !2, $17
    8    10        INIT_FCALL_BY_NAME                                       'curl_setopt'
         11        SEND_VAR_EX                                              !2
         12        FETCH_CONSTANT                                   ~19     'CURLOPT_URL'
         13        SEND_VAL_EX                                              ~19
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
    9    16        INIT_FCALL_BY_NAME                                       'curl_setopt'
         17        SEND_VAR_EX                                              !2
         18        FETCH_CONSTANT                                   ~21     'CURLOPT_FOLLOWLOCATION'
         19        SEND_VAL_EX                                              ~21
         20        SEND_VAL_EX                                              <true>
         21        DO_FCALL                                      0          
   10    22        INIT_FCALL_BY_NAME                                       'curl_setopt'
         23        SEND_VAR_EX                                              !2
         24        FETCH_CONSTANT                                   ~23     'CURLOPT_RETURNTRANSFER'
         25        SEND_VAL_EX                                              ~23
         26        SEND_VAL_EX                                              <true>
         27        DO_FCALL                                      0          
   11    28        INIT_FCALL_BY_NAME                                       'curl_setopt'
         29        SEND_VAR_EX                                              !2
         30        FETCH_CONSTANT                                   ~25     'CURLOPT_SSL_VERIFYPEER'
         31        SEND_VAL_EX                                              ~25
         32        SEND_VAL_EX                                              <false>
         33        DO_FCALL                                      0          
   12    34        INIT_FCALL_BY_NAME                                       'curl_exec'
         35        SEND_VAR_EX                                              !2
         36        DO_FCALL                                      0  $27     
         37        ASSIGN                                                   !3, $27
   13    38        INIT_FCALL_BY_NAME                                       'curl_close'
         39        SEND_VAR_EX                                              !2
         40        DO_FCALL                                      0          
   14    41        ISSET_ISEMPTY_CV                                 ~30     !3
         42        BOOL_NOT                                         ~31     ~30
         43      > JMPZ                                                     ~31, ->146
   15    44    >   ASSIGN                                           ~32     !5, <array>
         45        ASSIGN                                                   !4, ~32
   16    46        ASSIGN                                                   !6, <false>
   17    47        ASSIGN                                                   !7, 0
   18    48        INIT_FCALL                                               'explode'
         49        SEND_VAL                                                 '%0A'
         50        SEND_VAR                                                 !3
         51        DO_ICALL                                         $36     
         52      > FE_RESET_R                                       $37     $36, ->136
         53    > > FE_FETCH_R                                       ~38     $37, !8, ->136
         54    >   ASSIGN                                                   !9, ~38
   20    55        IS_IDENTICAL                                     ~40     !9, 0
         56      > JMPZ_EX                                          ~40     ~40, ->63
         57    >   INIT_FCALL                                               'stristr'
         58        SEND_VAR                                                 !8
         59        SEND_VAL                                                 'BEGIN%3AVCALENDAR'
         60        DO_ICALL                                         $41     
         61        TYPE_CHECK                                    4  ~42     $41
         62        BOOL                                             ~40     ~42
         63    > > JMPZ                                                     ~40, ->65
   21    64    > > JMP                                                      ->136
   24    65    >   INIT_FCALL                                               'trim'
         66        SEND_VAR                                                 !8
         67        DO_ICALL                                         $43     
         68        ASSIGN                                                   !8, $43
   26    69        INIT_FCALL                                               'stristr'
         70        SEND_VAR                                                 !8
         71        SEND_VAL                                                 'BEGIN%3AVEVENT'
         72        DO_ICALL                                         $45     
         73        TYPE_CHECK                                  1018          $45
         74      > JMPZ                                                     ~46, ->77
   27    75    >   ASSIGN                                                   !6, <true>
         76      > JMP                                                      ->135
   28    77    > > JMPZ                                                     !6, ->135
   30    78    >   INIT_FCALL                                               'stristr'
         79        SEND_VAR                                                 !8
         80        SEND_VAL                                                 'END%3AVEVENT'
         81        DO_ICALL                                         $48     
         82        TYPE_CHECK                                  1018          $48
         83      > JMPZ                                                     ~49, ->87
   31    84    >   ASSIGN                                                   !6, <false>
   33    85        PRE_INC                                                  !7
         86      > JMP                                                      ->135
   36    87    >   ISSET_ISEMPTY_DIM_OBJ                         1          !4, !7
         88      > JMPZ                                                     ~52, ->91
   37    89    >   ASSIGN_DIM                                               !4, !7
         90        OP_DATA                                                  <array>
   40    91    >   INIT_FCALL                                               'strpos'
         92        SEND_VAR                                                 !8
         93        SEND_VAL                                                 'DTSTART%3BVALUE'
         94        DO_ICALL                                         $54     
         95        IS_IDENTICAL                                             $54, 0
         96      > JMPZ                                                     ~55, ->112
   41    97    >   INIT_FCALL                                               'explode'
         98        SEND_VAL                                                 '%3A'
         99        SEND_VAR                                                 !8
        100        DO_ICALL                                         $56     
        101        ASSIGN                                                   !10, $56
   42   102        INIT_FCALL                                               'end'
        103        SEND_REF                                                 !10
        104        DO_ICALL                                         $58     
        105        ASSIGN                                                   !10, $58
   43   106        FETCH_DIM_W                                      $60     !4, !7
        107        ASSIGN_DIM                                               $60, 'date'
        108        OP_DATA                                                  !10
   45   109        ASSIGN_DIM                                               !5, !7
        110        OP_DATA                                                  !10
        111      > JMP                                                      ->135
   48   112    >   INIT_FCALL                                               'strpos'
        113        SEND_VAR                                                 !8
        114        SEND_VAL                                                 'SUMMARY%3A'
        115        DO_ICALL                                         $63     
        116        IS_IDENTICAL                                             $63, 0
        117      > JMPZ                                                     ~64, ->135
   49   118    >   INIT_FCALL                                               'explode'
        119        SEND_VAL                                                 '%2F'
        120        INIT_FCALL                                               'substr'
        121        SEND_VAR                                                 !8
        122        SEND_VAL                                                 8
        123        DO_ICALL                                         $65     
        124        SEND_VAR                                                 $65
        125        DO_ICALL                                         $66     
        126        FETCH_LIST_R                                     $67     $66, 0
        127        ASSIGN                                                   !11, $67
        128        FREE                                                     $66
   50   129        INIT_FCALL                                               'trim'
        130        SEND_VAR                                                 !11
        131        DO_ICALL                                         $71     
        132        FETCH_DIM_W                                      $69     !4, !7
        133        ASSIGN_DIM                                               $69, 'title'
        134        OP_DATA                                                  $71
   18   135    > > JMP                                                      ->53
        136    >   FE_FREE                                                  $37
   56   137        INIT_FCALL                                               'array_combine'
        138        SEND_VAR                                                 !5
        139        SEND_VAR                                                 !4
        140        DO_ICALL                                         $72     
        141        ASSIGN                                                   !4, $72
   57   142        INIT_FCALL                                               'ksort'
        143        SEND_REF                                                 !4
        144        DO_ICALL                                                 
   58   145      > RETURN                                                   !4
   60   146    > > RETURN                                                   null

End of function japan_holiday_ics

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.66 ms | 1411 KiB | 32 Q