...

# php help!!!!!

helen11
11-22-2011, 11:51 PM
php array

Fou-Lu
11-23-2011, 12:31 AM
In the future, please select a better title to describe the problem you are having. 'Help' doesn't help.
First thing first, what are you doing here: for(\$i=0;\$i<108;\$i++)? You only need to select a total of 9, not 108. The end result will be only nine months selected in total.
Next, the year's will not make sense in the format of 1, 2, 3... as you've shown here. February must have the number of days in the month calculated (which is a simple algorithm of:

if (\$iYear % 4 == 0)
{
\$bIsLeapYear = true;
if (\$iYear % 100 == 0)
{
if (\$iYear % 400 != 0)
{
\$bIsLeapYear = false;
}
}
}

which can also be done with a ternary). You can retrieve the current year using

\$d = getDate();
\$iYear = \$d['year'];

I don't understand what this means to not use array functions, but needing to use an array. I also don't understand what the random day assignment is about, something different from the days in the month? Due to this, I don't know what you will do with your running totals either.

Needless to say, you simply need to loop for the number of years, then create a numeric array of array with values full year and month chosen. Then loop through this, calculate the number of days in the month, and print a table with the year month and number of days. Use the \$months array to show which month is chosen.
I don't see a need to keep a running total nor a percentage. Neither is in use for the output.

helen11
11-23-2011, 01:46 AM
Anymore help would be greatly appreciated

Fou-Lu
11-23-2011, 03:41 AM
Anymore help would be greatly appreciated

Can you be more specific? This appears to be a homework assignment, so I cannot just provide you with working code (that I think would match the description above).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum