Daily Script

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 979
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Thu May 31, 2012 11:04 am

Yes but you will need to format your text file slightly different

Code: Select all

31/05/2012|This is the fact 1
01/06/2012|This is the fact 2
02/06/2012|This is the fact 3
03/06/2012|This is the fact 4
Once you have formatted the file like this you just read line by line and explode each line on the "|". Then compare the first element of the exploded line with the current date (formatted using d-m-Y) and if there is a match you display the second element of the line.

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 979
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Thu May 31, 2012 11:37 am

You won't really learn much with me handing you the script either though....

Read up on these functions (use php.net):
fopen - used to open files
explode - used to turn strings into arrays using a separator
date - generates a formatted date according to given format
strtotime - takes a given string and returns number of seconds since epoch
fgets - grabs a line of text from an open file
echo - outputs text to the browser

HopelessCode

Tue Jun 19, 2012 10:06 am

Um. Why not just check it with a cronjob, and then retrieve a quote from a mysql database, cache the result and boom?

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest