Logo
Word of the Day
Online Now: 0
Snippet Code
using a text file display a word or phrase for the day. Uses the line number for the current day.
This text file contains all of the words/phrases that will
be displayed on a certain day. This should have only one item/phrase
per line.

Example:

words.txt


Take me out to the ball game
Take me out to the park
Buy me some peanuts and crackerjacks
I don't care if we ever get back
Root, root, root for the home team
If they don't win its a shame
For its one, two, three strikes your out
at the old ball game.


WofD.php


<?php
    
function wordofday(){
        
$filename "words.txt";
        
$handle fopen($filename"r");
        
$contents fread($handlefilesize($filename));
        
fclose($handle);
        
$array explode("\n",$contents);
        
$date date("z");
        if(
$date count($array)){
            return 
$array[0];
        }else{
            return 
$array[$date];
        }
    }
    
    echo 
'<p>&nbsp;</p><p>'.wordofday().'</p>';
?>
 
Snippet Comments

Add Your Comment

credit card
2011-06-22 20:04:09
This pulls all the great information out of this word file. You did such a great job with this. I will be using this at work.
orlando network security
2011-06-21 19:04:51
This works so good. I set it up at work and it works so well. Keep up the good work.
Summer study abroad
2011-05-31 23:54:38
The national organizations urging Members of Congress to oppose efforts to weaken stability protections.Thanks for sharing the informative post. Regards. Roy.
Bows-n-Ties.com Press Release
2011-05-27 06:02:52
This basic snippet will calculate how many seconds it to a script to start and then end. Thanks for sharing the informative post. Regards. david77
buy memory foam mattress
2011-05-27 02:52:29
The phpcode is where your PHP resources flow and you can find tips and tricks of PHP coding.Thanks for sharing the informative post. Regards. david77
Ontario Cottage Rentals
2011-05-20 02:48:06
The biggest distributor and retailer of newspapers and magazines in Finland, the Netherlands and the Baltic countries with operation.Thanks for sharing the informative post. Regards. benny -
how to talk dirty
2011-05-20 02:17:38
The biggest distributor and retailer of newspapers and magazines in Finland, the Netherlands and the Baltic countries with operations.Thanks for sharing the informative post. Regards. benny -
php scripts
2010-09-14 00:31:07
it\'s ok. we just need the output but not the fucntion process. Good scripts.
Sam Yong
2009-07-25 00:00:00
yep i agree with matthew. you could have used mt_rand() or date('w')
Matthew
2008-08-21 00:00:00
date('z') returns the current day of the year (0-365).

The above example words.txt would only display different text for the first 7 days of the year, and then default to just displaying the first.

Add Your Comment

 
Snippet Tools
Rate this Snippet:

Rate the difficulty level:

Request Snippet Update


Suggested Difficulty Level: Intermediate
Current Score: 3.01
Total votes: 303
Total Views: 6959

Other top snippets by admin:

1. JPEG to ASCII Converter
2. Add (th, st, nd, rd, th) to the end of a number
3. Dynamic Page Content From Links
4. AJAX Quickie
5. Simple Image CAPTCHA

Search
Search for:







User Panel

User name:

Password:

Register And Post Your Own Snippets

New Snippets

1.  Shorten text and (4 of 1)

2.  file-based simple guest (0 of 0)

3.  adding an entry (0 of 0)

4.  integer to currency (1.33 of 3)

5.  Aggregate IP addresses (0 of 0)

6.  file handling (0 of 0)

7.  testing system with (0 of 0)

8.  Make an php (1 of 1)

9.  allow download in (5 of 1)

10.  redirect in 3 (0 of 0)

11.  live clock with (0 of 0)

12.  visit counter (3.5 of 2)

13.  contact form with (4 of 1)

14.  show a specific (0 of 0)

15.  The & sign (0 of 0)

16.  static variable in (0 of 0)

17.  multiplication table with (0 of 0)

18.  function with multiplicationt (0 of 0)

19.  php generated menu (0 of 0)

20.  drawing a table (0 of 0)

21.  embedded array (one (0 of 0)

22.  checks the week (0 of 0)

23.  put links on (4.5 of 2)

24.  Directory Image Gallery (0 of 0)

25.  TOS (4 of 1)

Home | Forum | Free PHP Web Hosting | Contact | Terms & Conditions |  
Donate
PHPSnips.com - ©2012 Amethyst Creative