Stop if word is found?
| From: | Jan Grafström | Date: | Wed, 09 May 2001 05:16:00 +0000 |
| Subject: | Stop if word is found? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-52026@lists.php.net to get a copy of this message | ||
Hi!
I am searching some files for a word and if word is found I will stop
the script.
I tried with die, but I have never used it before and it didn´t work
perhaps I used it in a wrong way..
$fd = fopen($filename1, "r");
$string = fread($fd, filesize($filename1));
$fruits = explode (" ", $string);
fclose($fd);
while (list ($key, $val) = each ($fruits)) {
if (eregi("$word", $val)) {
print "$filename1".",".$key;
}
}
$fd = fopen($filename2, "r");
$string = fread($fd, filesize($filename2));
$fruits = explode (" ", $string);
fclose($fd);
while (list ($key, $val) = each ($fruits)) {
if (eregi("$word", $val)) {
print "$filename2".",".$key;
}
}
------
If I put in a word wich is found in both files than I got two answers
but I only wan´t
to know the first one. Can I prevent it to run if the word is found in
file1?
Thanks in advance for helping me.
Regards
Jan