Using fopen()/fread()/fscanf()
| From: | Jason Soza | Date: | Tue, 23 Jul 2002 03:17:59 +0000 |
| Subject: | Using fopen()/fread()/fscanf() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-109011@lists.php.net to get a copy of this message | ||
I think I'm pretty close to getting this right (maybe!), I've been reading
through the manual, but can't seem to work it out. I keep getting this
error:
[Mon Jul 22 19:03:24 2002] [error] PHP Warning: Supplied argument is not a
valid File-Handle resource in index.php on line 66
I'm trying to open a URL, read the contents, then pull out specific info
found between specific HTML tags. This is what I have so far:
63| <?php
64| $filename =
fopen("http://www.kinyradio.com/juneaunews/latest_juneau_news.html",
"r");
65| $contents = fread($filename, 1000000);
66| while($headlines = fscanf($filename, "<p style=\"padding-left:
45\"><font face=\"Verdana\" size=\"3\"><b>%[a-zA-Z0-9,.
]</b></font>",
$headline)) {
67| extract($headlines);
68| print "<a
href=\"http://www.kinyradio.com/juneaunews/latest_juneau_news.html\">$headli
ne</a><br>";
69| }
70| fclose($filename);
71| ?>
Any ideas? Any other functions I could try instead of fscanf()?
TIA,
Jason Soza