Created
February 10, 2014 13:45
-
-
Save mogetutu/8916188 to your computer and use it in GitHub Desktop.
Akirachix, Exercise 12 - Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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