I'm trying to extract HTML code from a website.
First, I insert the HTML into a .txt file. Then, another page fopens the txt file while str_replacing selected regex.
I keep getting resource ID #4 on this below script. I don't know why information is not passing through. I'm rusty.
I want to trim the selected data from the .txt file and insert it into another .txt file.
<?php
set_time_limit(0);
error_reporting(E_ALL);
$fp = fopen('newfile2.txt', 'r');
echo '$fp is resource = ' . (is_resource($fp) ? 'true': 'false');
$re = '/(\n*.*+)+\1<tr>\n.*<td bgcolor=\"#ffffcc\">/';
$subst = "<tr><td>";
$result = str_replace( $re, $subst, $fp);
$put = file_put_contents("newfile3.txt", $result);
print_r($result);
echo 'testjn';
?>