I have a small problem. I need to get a line from a text file using PHP. Here is an example of the text file:
hello 2010-10-25
hello 2010-10-26
hello 2010-10-27
hello 2010-10-28
hello 2010-10-29
hello 2010-10-30
hello 2010-10-31
And my code for taking out a the line which contains "2010-10-26" is this:
<?php
$datefile = fopen('file.txt', 'r') or exit("Unable to open file.txt");
while(!feof($datefile))
{
$date = "2010-10-26";
$string = fgets($datefile);
if(strpos($string, $date)==true)
{
echo fgets($datefile);
}
}
fclose($datefile);
?>
Instead of printing out the line "hello 2010-10-26", it prints out "hello 2010-10-27" I have no idea whats going on, please help.