Skip to content

Instantly share code, notes, and snippets.

@jrmadsen67
Created November 11, 2012 08:56
Show Gist options
  • Save jrmadsen67/4054208 to your computer and use it in GitHub Desktop.
Save jrmadsen67/4054208 to your computer and use it in GitHub Desktop.
php - create days of week array from functions
$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);
@jrmadsen67
Copy link
Author

The whole point, of course, is to write it in a way that is actually longer than just typing.. $array(0=>'Sunday', 1=> ... );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment