Web Analytics Made Easy -
StatCounter Script Help - CodingForum

Announcement

Collapse
No announcement yet.

Script Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script Help

    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

  • #2
    Try this.

    PHP Code:
    <?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];
    ?>
    If you can't stand behind your troops, feel free to stand in front of them
    Semper Fidelis

    Comment


    • #3
      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 Code:
      <?php
      $text 
      = array(
          
      => 'Text for january',
          
      => 'Text for february',
          
      //....
      );

      print 
      $text[date('n')];
      ?>
      PHP Code:
      header('HTTP/1.1 420 Enhance Your Calm'); 
      Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

      Comment


      • #4
        Ooops missed that. Thanks
        If you can't stand behind your troops, feel free to stand in front of them
        Semper Fidelis

        Comment


        • #5
          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

          Comment


          • #6
            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.
            Dave .... HostMonster for all of your hosting needs

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎