note 84373 added to function.date
| From: | RobA dot at osu1 dot php dot net | Date: | Thu, 10 Jul 2008 16:38:13 +0000 |
| Subject: | note 84373 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141379@lists.php.net to get a copy of this message | ||
Quick function for returning the names of the next 7 days of the week starting with today.
Returns an array that can be formatted to your liking.
<?php
/**
* Returns array of next 7 days starting with today
*
*/
function next_7_days() {
// create array of day names. You can change these to whatever you want
$days = array(
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday');
$today = date('N');
for ($i=1;$i<$today;$i++) {
// take the first element off the array
$shift = array_shift($days);
// ... and add it to the end of the array
array_push($days,$shift);
}
// returns the sorted array
return $days;
}
?>
It basically takes an array starting with Monday and shifts each day to the end of the array until
the first element in the array is today.
----
Server IP: 64.71.164.2
Probable Submitter: 70.164.245.157
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/84373
Del: integrated -- https://master.php.net/note/delete/84373/integrated
Del: useless -- https://master.php.net/note/delete/84373/useless
Del: bad code -- https://master.php.net/note/delete/84373/bad+code
Del: spam -- https://master.php.net/note/delete/84373/spam
Del: non-english -- https://master.php.net/note/delete/84373/non-english
Del: in docs -- https://master.php.net/note/delete/84373/in+docs
Del: other reasons-- https://master.php.net/note/delete/84373
Reject -- https://master.php.net/note/reject/84373
Search -- https://master.php.net/manage/user-notes.php