Skip to content

Instantly share code, notes, and snippets.

@mogetutu
Created February 10, 2014 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mogetutu/8916188 to your computer and use it in GitHub Desktop.
Save mogetutu/8916188 to your computer and use it in GitHub Desktop.
Akirachix, Exercise 12 - Example
<?php
// the year the use passing is a leap year
// then assign feb 28/29
// $timestamp = strotime('2013-01-01')
// date('L', $timestamp)
function isLeapYear($year)
{
// Tell us if this is a leap year
$isLeapYear = date('L', strtotime("$year-01-01"));
if($isLeapYear == 1)
{
return 29; //Leap year days
}
else
{
return 28; //Non-leap year days.
}
}
// assign the correct days to february
$february_days = isLeapYear($user);
// Example of months array
$months = array(
'January' => 31,
'February' => $february_days,
'March' => 31,
'April' => 30
);
// View the months array
var_dump($months);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment