PHP or math question re: random number

Get answers here.

Moderators: BBear, theunknownhost, flaguy

Post Reply
User avatar
Official Test Penquin
Posts: 3337
Joined: Tue Nov 19, 2002 2:50 am
Location: Canada

PHP or math question re: random number

Post by Sapphyre » Thu Sep 08, 2011 5:20 pm

I came across this snippet in a script we're using

Code: Select all

$number = (rand()%12)+1
Am I deciphering it correctly - does it generate a random number between 1 and 12 inclusive ? If I have researched correctly, % in math means mod/modulus - this means the remainder after division.

Showing my age ... I don't recall learning modulus when I graduated HS and college \d\d years ago, not even in statistics.

User avatar
Official Test Penquin
Posts: 9103
Joined: Tue Apr 09, 2002 12:00 am
Location: IDAHO, USA

Post by Arf » Fri Sep 09, 2011 12:47 am

yeah, they don't teach that in regular U.S.A. public school either. You have to be in a smart class to get that stuff.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest