Created
November 11, 2012 08:56
-
-
Save jrmadsen67/4054208 to your computer and use it in GitHub Desktop.
php - create days of week array from functions
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
$date = new DateTime('first Sunday'); | |
$weeksdays_array = array_map(function($val) use ($date) {return $date->add(new DateInterval('P'.$val.'D'))->format('l');}, range(0,6)); | |
var_dump($weeksdays_array); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The whole point, of course, is to write it in a way that is actually longer than just typing.. $array(0=>'Sunday', 1=> ... );