Hey Guys,
I am a little new to PHP and I was wondering, I have a txt file with the following format:
Anniversary First Last name.
I basically want to write a PHP script that will grab the first column from the file (anniversary) and validate it against the current date and out put how long you've been there.
I know how to get todays date and validate it against another, but I don't know how to read it from the first column of the file. Can someone help?
Thanks
Read column until EoF
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Read column until EoF
Assuming you don't have spaces in the dates, this should get you started:
Code: Select all
$lines = file('yourfile.txt', FILE_SKIP_EMPTY_LINES);
foreach($lines as $line) {
$cols = explode(' ', $line);
echo $cols[0];
}mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.