I am new to php.
I would like to write a scripts which takes part of a html file and saves it into another file. I have a script running on my site and I need to modify the output. I don't or can't change the script so I want to do it outside the script.
Below is just and example of how this could work.
However I get an error;
" Warning: Unknown modifier 't' in /home/xcalak/public_html/scripts/mweather/url_modify.php on line 20"
<?php
$url_name = "http://www.xcalak.info/scripts/mweather/mweather.php";
//URL to open
$file_name = "weather.txt";
// File to store result in
$start = '<title>';
$end = '</title>';
// Get text between start and end
$fp = fopen ($url_name, 'r') or die('Unable to open file'.$url_name.' for reading');
while (!feof ($fp))
{
$buf = trim(fgets($fp, 4096));
$cont .= $buf
}
preg_match("/$start(.*)$end/s",$cont,$match);
$result = 'the title of '.$url_name.' is <b>'.$match[1].'</b>';
$file_pointer = fopen($file_name, "w");
// "w" is the mode, or the action we're
// going to perform on the file
fwrite($file_pointer, $result);
// Writing to the file, after truncating it to 0 bytes
fclose($file_pointer);
// close file
print "data written";
?>
Any body know what I did wrong?
Thanks,
Hanno