...

View Full Version : Script Help



Hayes
08-28-2011, 12:38 PM
Hi, I am looking to create a script in PHP that automatically changes text once a month so for example in December I want a certain bit of text to show and in January Another. Hope that makes sense

Thanks in advance
Danny

jimhill
08-28-2011, 03:40 PM
Try this.


<?php
$month=date(m);
$text=array("01"=>"January","02"=>"February","03"=>"March","04"=>"April","05"=>"May","06"=>"June","07"=>"July","08"=>"August","09"=>"September","10"=>"October","11"=>"November","12"=>"December");
echo $text[$month];
?>

Fou-Lu
08-28-2011, 05:30 PM
The only thing I'd change from the above is I'd use n instead of m (btw you'll have an undefined constant from the m in there jh).


<?php
$text = array(
1 => 'Text for january',
2 => 'Text for february',
//....
);

print $text[date('n')];
?>

jimhill
08-28-2011, 06:25 PM
Ooops missed that. Thanks

Hayes
09-02-2011, 11:58 AM
Thank you for the replys but dont think I described it to well, what I need is something that in july will say for example its hot and in december for example say its cold and have these automatically change at the beginning of every month

djm0219
09-02-2011, 12:17 PM
What Fou-Lu posted will do exactly that. Whatever text you put in the array for each month will be displayed for that month and change on the first of every month.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum