Re: Help plz!
| From: | Richard Lynch | Date: | Tue, 12 Dec 2000 19:13:23 +0000 |
| Subject: | Re: Help plz! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29941@lists.php.net to get a copy of this message | ||
You close the file after you find </title>, and then try to call feof() on
it in your for() loop... You can't fall feof() on a closed file. It's
already done and gone.
Add a $done flag that starts off "false", and set it to "true" when you find
</title> and use !$done && !feof($fp) in your for() test.
> What is wrong in this script. It reports "Warning: Unable to find file
> identifier 2 ......skip skip....ist.php3 on line 10"
>
> <?php
> $build = "";
> $flag = 0;
> $handle=opendir('.');
> while ($file = readdir($handle))
>
> if ($file != "." && $file != ".." &&
> ereg(".htm$", $file))
>
> $fp = fopen ("$file", "r");
> for ($i=0; !feof($fp); $i++){
> $line = fgets($fp, 1024);
> if (ereg("^<title>", $line))
> $flag = 1;
> if ($flag == 1)
> $build = $build.$line;
> if (ereg("</title>", $line)) {
> $flag = 0;
> fclose ($fp);
> }
> }
> if ($build > ""){
> $build = ereg_replace("<title>", "", $build);
> $build = ereg_replace("</title>", "", $build);
> $build = trim($build);
> $tit=$build;
> $build="";
> }
> echo "<tr><td>";
> echo "<a href=";
> echo $file;
> echo ">";
> echo $tit;
> echo "</a></td>";
> }
> }
> closedir($handle);
> ?>
> It
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>