Jump to content

seperate array and change to a variable


jonnyfortis

Recommended Posts

i have a student register for attendance, down the side will be their names, across the top i will be showing each single day (example tuesday) from three month date range

 

currently the code just echoes out all the Tuesdays as an array from the three month date range. i need to be able to use the individual date to add them to the database based on weather they student has attended. i know how to do this i just need to know how i can use the dates individually.

function getDatesFromRange($start, $end) {
    $interval = new DateInterval('P1D');

    $realEnd = new DateTime($end);
    $realEnd->add($interval);

    $period = new DatePeriod(
         new DateTime($start),
         $interval,
         $realEnd
    );

    foreach($period as $date) { 
        $array[] = $date->format('Y-m-d'); 
    }

    return $array;
}

// Call the function
$dates = getDatesFromRange('2016-04-01', '2016-07-01');

// Print the output
print_r($dates);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.