3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Setting up curl function curl($url) { $ch = curl_init(); // Starting cURL curl_setopt($ch, CURLOPT_URL, $url); // Defining URL function curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL options $data = curl_exec($ch); // Begin the operation curl_close($ch); // Stopping cURL return $data; // Saving the data } ?> <?php // Culling the data function scrape_between($data, $start, $end){ $data = stristr($data, $start); // Removing all data before starting point $data = substr($data, strlen($start)); // Stripping $start $stop = stripos($data, $end); // Defining the end point $data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrap return $data; // Saving the data } ?> <?php $scraped_page = curl("http://www.hko.gov.hk/aviat/amt_e/atis.htm"); // Defining the page to be grabbed $scraped_data = scrape_between($scraped_page, "A-RUNWAY", "</tr>"); // Defining the data to grab $atis = str_replace("</td><td class=atislines align=\"left\">","",$scraped_data); // Removing unnecessary code $atis2 = str_replace("</td>","",$atis); // Removing unnecessary code $scraped_data_d = scrape_between($scraped_page, "D-RUNWAY", "</tr>"); // Defining the data to grab $atis_d = str_replace("</td><td class=atislines align=\"left\">","",$scraped_data_d); // Removing unnecessary code $atis2_d = str_replace("</td>","",$atis_d); // Removing unnecessary code echo "Active Runway: " . $atis2; "<br>" ;// HTML Code being written echo "Second Runway: " . $atis2_d; "<br>" ;// HTML Code for D-Runway ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vH8lg
function name:  (null)
number of ops:  47
compiled vars:  !0 = $scraped_page, !1 = $scraped_data, !2 = $atis, !3 = $atis2, !4 = $scraped_data_d, !5 = $atis_d, !6 = $atis2_d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     '%0A'
   23     1        ECHO                                                     '%0A'
   25     2        INIT_FCALL                                               'curl'
          3        SEND_VAL                                                 'http%3A%2F%2Fwww.hko.gov.hk%2Faviat%2Famt_e%2Fatis.htm'
          4        DO_FCALL                                      0  $7      
          5        ASSIGN                                                   !0, $7
   26     6        INIT_FCALL                                               'scrape_between'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 'A-RUNWAY'
          9        SEND_VAL                                                 '%3C%2Ftr%3E'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !1, $9
   27    12        INIT_FCALL                                               'str_replace'
         13        SEND_VAL                                                 '%3C%2Ftd%3E%3Ctd+class%3Datislines+align%3D%22left%22%3E'
         14        SEND_VAL                                                 ''
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $11     
         17        ASSIGN                                                   !2, $11
   28    18        INIT_FCALL                                               'str_replace'
         19        SEND_VAL                                                 '%3C%2Ftd%3E'
         20        SEND_VAL                                                 ''
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $13     
         23        ASSIGN                                                   !3, $13
   30    24        INIT_FCALL                                               'scrape_between'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 'D-RUNWAY'
         27        SEND_VAL                                                 '%3C%2Ftr%3E'
         28        DO_FCALL                                      0  $15     
         29        ASSIGN                                                   !4, $15
   31    30        INIT_FCALL                                               'str_replace'
         31        SEND_VAL                                                 '%3C%2Ftd%3E%3Ctd+class%3Datislines+align%3D%22left%22%3E'
         32        SEND_VAL                                                 ''
         33        SEND_VAR                                                 !4
         34        DO_ICALL                                         $17     
         35        ASSIGN                                                   !5, $17
   32    36        INIT_FCALL                                               'str_replace'
         37        SEND_VAL                                                 '%3C%2Ftd%3E'
         38        SEND_VAL                                                 ''
         39        SEND_VAR                                                 !5
         40        DO_ICALL                                         $19     
         41        ASSIGN                                                   !6, $19
   34    42        CONCAT                                           ~21     'Active+Runway%3A+', !3
         43        ECHO                                                     ~21
   35    44        CONCAT                                           ~22     'Second+Runway%3A+', !6
         45        ECHO                                                     ~22
   36    46      > RETURN                                                   1

Function curl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vH8lg
function name:  curl
number of ops:  25
compiled vars:  !0 = $url, !1 = $ch, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL_BY_NAME                                       'curl_init'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
    5     4        INIT_FCALL_BY_NAME                                       'curl_setopt'
          5        SEND_VAR_EX                                              !1
          6        FETCH_CONSTANT                                   ~5      'CURLOPT_URL'
          7        SEND_VAL_EX                                              ~5
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
    6    10        INIT_FCALL_BY_NAME                                       'curl_setopt'
         11        SEND_VAR_EX                                              !1
         12        FETCH_CONSTANT                                   ~7      'CURLOPT_RETURNTRANSFER'
         13        SEND_VAL_EX                                              ~7
         14        SEND_VAL_EX                                              <true>
         15        DO_FCALL                                      0          
    7    16        INIT_FCALL_BY_NAME                                       'curl_exec'
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $9      
         19        ASSIGN                                                   !2, $9
    8    20        INIT_FCALL_BY_NAME                                       'curl_close'
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0          
    9    23      > RETURN                                                   !2
   10    24*     > RETURN                                                   null

End of function curl

Function scrape_between:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vH8lg
function name:  scrape_between
number of ops:  27
compiled vars:  !0 = $data, !1 = $start, !2 = $end, !3 = $stop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   16     3        INIT_FCALL                                               'stristr'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !0, $4
   17     8        INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !0
         10        STRLEN                                           ~6      !1
         11        SEND_VAL                                                 ~6
         12        DO_ICALL                                         $7      
         13        ASSIGN                                                   !0, $7
   18    14        INIT_FCALL                                               'stripos'
         15        SEND_VAR                                                 !0
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !3, $9
   19    19        INIT_FCALL                                               'substr'
         20        SEND_VAR                                                 !0
         21        SEND_VAL                                                 0
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                         $11     
         24        ASSIGN                                                   !0, $11
   20    25      > RETURN                                                   !0
   21    26*     > RETURN                                                   null

End of function scrape_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.21 ms | 952 KiB | 25 Q