0

So I have been successful at gathering the first scrape in the code, but the secondary scrape within the foreach loop results in no values. I can't seem to figure out what I'm doing wrong logically.

Code Snippet:

// Defining the basic scraping function
function scrape_between($data, $start, $end){
    $data = stristr($data, $start); // Stripping all data from before $start
    $data = substr($data, strlen($start));  // Stripping $start
    $stop = stripos($data, $end);   // Getting the position of the $end of the data to scrape
    $data = substr($data, 0, $stop);    // Stripping all data from after and including the $end of the data to scrape
    return $data;   // Returning the scraped data from the function
}


$scraped_site = curl("http://inciweb.nwcg.gov/");
$scraped_data = scrape_between($scraped_site, "<table>", "</table>");


$separate_results = explode("<tr>", $scraped_data);

$count = 0;
$info_arr = array();



foreach ($separate_results as $row) {
    ++$count;
    $info_arr[$count] = $row;
    $scraped_data2 = scrape_between($row, "<td>", "</td>");
    echo $scraped_data2;

}

foreach($info_arr as $info) {
    ?>
    <div>
        <label name="fire_info" value="<?php echo $info; ?></label>
    </div>


<?php   
}
?>
Jb1128
  • 87
  • 2
  • 10
  • what are you trying to get ? as far as I know, `curl` isn't a function in php, did you mean `curl_init();` ? – Pedro Lobito May 12 '16 at 00:12
  • @Pedro Lobito I should've included it, but I defined my own function named curl containing curl_init() within. I am trying to retrieve the individual columns from my table row results – Jb1128 May 12 '16 at 00:34

0 Answers0