Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read file into an array

Status
Not open for further replies.

mynameisfred

Programmer
Feb 3, 2003
3
GB
Hay

If i have a txt file with
name, 00/00/0000
name2, 11/11/1111
etc

i would like to read them into an array

I need to have each line split but i also need to then look at the bit after the comma to see if it matches todays date...if it does then print name, 00/00/0000

any ideas?

thanks
 
ok going to look at thoses links and then post back what i come up with....is that what i am suppost to do ? i am new?
 
ok i tried to make a start but it is not working how i would like!! i need to read the date of birth first then once i sort this out i can then see if it matches today then print name and there age....but need to sort this first


file looks like:
*********************************
Sarah Patterson, 03/03/1982, test for today, 04/02/1901, Chris Lawrence, 03/07/1982, James Mills, 01/01/1981,
*********************************

code:
*********************************

$file = "data/birthdays.txt";
$fp = fopen($file,"r+");

while (!feof($fp))
{
$line = fgetcsv($fp , 4096);
}

$n = 0;
for ($n < count($fp); $n++;)
{
print &quot;$line[$n] <br>&quot;;
}


fclose($fp);
*********************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top