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;// HTML Code being written echo "Second Runway: " . $atis2_d;// HTML Code for D-Runway ?>

preferences:
31.52 ms | 402 KiB | 5 Q