who can tell me why when I use explode with the following I can't create an array
Anyone see what I'm missing here?
$hours = array('8-9','9-10','10-11','11-12','12-1p','1-2p','2-3p','3-4p','4-5p','5-6p','6-7p','7-8p','8-9p');
for($i=0; $i<count($hours); $i++) {
$times = "*$hours[$i]";
echo "$times";
}
This will produce a bulleted list string with everything in the array
But when I explode the string - like so:
$findtimes = explode('*', $times); and loop through it - I only get the last element of the string - "8-9p"
should I not get the same array as above but w/o bullets ?
any help is appreciated - driving me nuts.
here's more complete code ///
<?
$start_time ="10:00AM";
$end_time ="1:00PM";
if($start_time =="10:00AM"){
$begin = 2;
}
if($end_time =="1:00PM"){
$end = 5;
}
?>
<?
$hours = array('8-9','9-10','10-11','11-12','12-1p','1-2p','2-3p','3-4p','4-5p','5-6p','6-7p','7-8p','8-9p');
for($i=$begin; $i<$end; $i++) {
$times = "*$hours[$i]";
echo "$times";
}
?>
<?
$findtimes = explode('*',$times);
if(in_array('10-11',$findtimes)) {
$eight = '1';
}else{
$eight ='0';
}
?>
Any help is appreciated.
MS