Page 1 of 1

Random Quote + Time Variable

Posted: Sat Feb 22, 2003 4:45 pm
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!!

Re: Random Quote + Time Variable

Posted: Sat Feb 22, 2003 8:43 pm
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

Hmm

Posted: Sat Feb 22, 2003 9:59 pm
by Jujimufu
Wow! I think i'll try that man.. Thanks! I'll see what happens..

OH MY GOD!

Posted: Sat Feb 22, 2003 10:37 pm
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 :)

Posted: Sat Feb 22, 2003 10:39 pm
by evilcoder
that some pretty simple code... I really suggest you read up about operators in the PHP.net manual.