Random Quote + Time Variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jujimufu
Forum Newbie
Posts: 3
Joined: Sat Feb 22, 2003 4:45 pm

Random Quote + Time Variable

Post by Jujimufu »

Hi guys! I'm new to PHP but i'm writing this script. This is what I "WANT" it to do >

I want to have it execute 1 thing in array 1 randomly if the hour of the day is let's say X.

And if that time of day is not X, then I want it to execute a quote from another array, let's say array 2.
------------------------------------------------------------------------------
2 author's of the quote system, and basically every other hour of the day I want it to switch between the arrays. Each array is just a collection of quotes by these 2 authors. Okay well it doesn't work... So i've included it here > to go look at it's a txt doc >

http://www.trickstutorials.com/randomquote.txt

Just tell me what's wrong with it, I think it's simple I'm just not picking up on it guys. Thanks in advance! I'd really appreciate some help on this guys! PHP ROX!!
jiop
Forum Newbie
Posts: 11
Joined: Wed Dec 18, 2002 4:00 am
Location: newport beach

Re: Random Quote + Time Variable

Post by jiop »

how about you assign all odd numbers of the day for array 1
and all even numberes of the day for array 2

you can use the modulus operator (%) to check whether the hour is odd or even

so say like its 12pm. you would do something like this

Code: Select all

$check_time = $hour % 2;
if ($check_time == 0)
{
  // output quote from array 1
}

else
{
  // output quote from array 2
}
err hope that helps, i'm a newbie like you :D
Jujimufu
Forum Newbie
Posts: 3
Joined: Sat Feb 22, 2003 4:45 pm

Hmm

Post by Jujimufu »

Wow! I think i'll try that man.. Thanks! I'll see what happens..
Jujimufu
Forum Newbie
Posts: 3
Joined: Sat Feb 22, 2003 4:45 pm

OH MY GOD!

Post by Jujimufu »

I COULD KISS YOU! I've been trying for 2 days lol!! THANK YOU SO MUCH BITCH HAHAH!! YOU KICK ASS THANKS SO MUCH!!! I COULD HUG YOU BUT I DOn'T KNOW YOU :)
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

that some pretty simple code... I really suggest you read up about operators in the PHP.net manual.
Post Reply