Hello all,
I am trying to create a php script that will search a text file for a specific date and set the description which corresponds to that date to a variable.
Here is a sample of what the txt file might look like
0720 "This is description 1"
0721 "This is description 2"
0722 "This is description 3"
0723 "This is description 4"
And here is what I have so far.
<?php
$mon = date(m);
$date = date(d);
$datecode = $mon.$date;
$filename = "descriptions.txt";
$handle = fopen($filename, "r");
while ($dateinfo = fscanf($handle, "%s\t%s\t%s\n"))
{
list ($date, $description) = $dateinfo;
if ($date == $datecode)
{
$a = $description;
//some code here to end the while loop, maybe set $dateinfo = null?
}
}
fclose($handle);
?>
The script finds the right date, but my problem is that $a is set to equal "This I want $a to equal the entire string This is description 1
Any advice would be greatly appreciated.
Thank you.