Okay, this is the problem....theres a matrix of 0's and 1's taht correspond the time slots and the days of the week on whether you can work or not during the time block. If it's a 1, you can work, if it's a 0, you're unavailable.
I'm trying to set it up for sunday first so I can apply it to the rest of the week, and the method for sunday will apply to mon-sat.
The time blocks are these:
8:00-9:15am => X1
9:45-11:00am => X2
11:15-12:30pm => X3
1:00-2:15pm => X4
2:30-3:45pm => X5
4:25-5:30pm => X6
6:30-7:45pm => X7
8:15-9:30pm => X8
Now, what I'm trying to do is, say you have 1's at x1, x2, x3, and x6, x7, x8, but 0's at x4, and x5.
so you can work from 8:00-12:30, and 4:25 - close.
How can I setup some loops....or something, to make it say that?
My current code:
PHP Code:
$sun=1;
while($sun <= 50)
{
if($hours[$sun] == 1)
{
switch($sun)
{
case 1:
$_SESSION['aSundayHours'] .= '8:00-9:15 am, ';
break;
case 8:
$_SESSION['aSundayHours'] .= '9:45-11:00 am, ';
break;
case 15:
$_SESSION['aSundayHours'] .= '11:15-12:30 pm, ';
break;
case 22:
$_SESSION['aSundayHours'] .= '1:00-2:15 pm, ';
break;
case 29:
$_SESSION['aSundayHours'] .= '2:30-3:45 pm, ';
break;
case 36:
$_SESSION['aSundayHours'] .= '4:25-5:30 pm, ';
break;
case 43:
$_SESSION['aSundayHours'] .= '6:30-7:45 pm, ';
break;
case 50:
$_SESSION['aSundayHours'] .= '8:15-9:30 pm, ';
break;
}
}
$sun = $sun + 7;
}
But that will output:
Code:
8:00-9:15 am, 9:45-11:00 am, 11:15-12:30 pm, 4:25-5:30 pm, 6:30-7:45 pm, 8:15-9:30 pm,
I guess my main questions, is what's the best way to have a string of 1's and 0's and finding the groups of 1's and classifying them. Any questions, please ask, and any help is awesome!!!