Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: php help!!!!!

  1. #1
    New Coder
    Join Date
    Nov 2011
    Location
    South Africa
    Posts
    57
    Thanks
    14
    Thanked 0 Times in 0 Posts

    php help!!!!!

    php array
    Last edited by helen11; 11-23-2011 at 08:19 AM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    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:
    PHP Code:
    if ($iYear == 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
    PHP Code:
    $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.

  • Users who have thanked Fou-Lu for this post:

    helen11 (11-22-2011)

  • #3
    New Coder
    Join Date
    Nov 2011
    Location
    South Africa
    Posts
    57
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Anymore help would be greatly appreciated

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by helen11 View Post
    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).


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •