Hi there,
How would you go about shifting the array so that the start of the array is the variable $startofweek
$daysofweek = array(Sun, Mon, Tue, Wed, Thu, Fri, Sat);
e.g
if $startofweek=Wed
then:
$daysofweek = array(Wed, Thu, Fri, Sat, Sun, Mon, Tue);
I was thinking a about using a while loop along these lines
while ($daysofweek[0] != $startofweek) {
array_shift($daysofweek);
}
Though I didn't like fact that it may loop indefinatley if $startofweek is assigned incorrectly.
Just wandered how a "real" developer would code it
How would you go about shifting the array so that the start of the array is the variable $startofweek
$daysofweek = array(Sun, Mon, Tue, Wed, Thu, Fri, Sat);
e.g
if $startofweek=Wed
then:
$daysofweek = array(Wed, Thu, Fri, Sat, Sun, Mon, Tue);
I was thinking a about using a while loop along these lines
while ($daysofweek[0] != $startofweek) {
array_shift($daysofweek);
}
Though I didn't like fact that it may loop indefinatley if $startofweek is assigned incorrectly.
Just wandered how a "real" developer would code it