----- Original Message ----- From: "joel boonstra" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 16, 2004 3:35 PM Subject: Re: [PHP] odd and even numbers
> On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote: > > function isOdd ($value) { > > return (int)$value % 2 ? true : false; > > } > > > > Returns true/false if the value is odd. Also rounds down floating point numbers given as the test value. > > No need to explicitly state "true" and "false". Just negate the result > of your modulus operator, and take advantage of the fact that "0" is > false, and "1" is true: > > function isOdd ($value) { > return !((int)$value % 2); > } > > -- > [ joel boonstra | gospelcom.net ] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > This worked.. somewhat.. here is what I want to do though. I have two people checking the same email address. I want to break up the emails 50/50 to each person. What values can I put into the random number generator so that I can get closer to 50/50. I just set up a test page with: $rand = rand(1, 501); echo $rand; if ($rand % 2 == 0) echo "even"; else echo "odd"; and I'm getting a lot more evens than odds, so the one person would get more emails than the other. Is there any substitution to rand that I could use to get one message to go to one person, then the next to the other? I'd like it to be as close to 50/50 as possible. any questions, let me know Thanks, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php