PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
define(FILENAME, "filename.txt");
$fp = fopen(FILENAME, "r") or die ("Failed to open " . FILENAME);
while (!feof($fp))
{
$line = fgets($fp, 1024);
if (ereg("SEARCHSTRING", $line, $results))
{
print $resultsї0];
}
}
Try that, get back to me with results?
Last edited by nigma on Sun Aug 17, 2003 9:05 pm, edited 1 time in total.
Warning: fopen(): Unable to access testtxt in /home/virtual/site9/fst/var/www/html/tradingsystem/searchtest.PHP on line 2
Warning: fopen(testtxt): failed to open stream: No such file or directory in /home/virtual/site9/fst/var/www/html/tradingsystem/searchtest.PHP on line 2
Failed to open testtxt
<?php
define(FILENAME, "test.txt");
if (file_exists(FILENAME))
{
$fp = fopen(FILENAME, "r") or die ("Failed to open " . FILENAME);
while (!feof($fp))
{
$line = fgets($fp, 1024);
if (ereg("test", $line, $results))
{
print $resultsї0];
}
}
}
else
{
print FILENAME . " could not be opened.";
}
?>
I would make it find Name.. but how would I make it find The value "nick" because you will be able to change it. so you can't search for the word "nick"