This is my array:
Array
(
[F] => 09:00 - 18:00
[M] => 09:00 - 18:00
[Th] => 09:00 - 18:00
[W] => 09:00 - 18:00
[T] => 09:00 - 18:00
[Su] => RD
[Sa] => RD
)
and I want to produce this output:
MTWThF 9:00 - 18:00 SaSu RD
this is my code:
array_s=array(
F => 09:00 - 18:00
M => 09:00 - 18:00
Th => 09:00 - 18:00
W => 09:00 - 18:00
T => 09:00 - 18:00
Su => RD
Sa => RD
)
asort($array_s);
$temp_s = '';
foreach($array_s as $key => $value){
if($temp_s == null){
$temp_s = $value; //first array
$temp_day = $key;
$res_day .= $temp_day;
}else{
if($value == $temp_s){
$res_day .= $key;
}else{
echo $res_day ." ". $temp_s;
$res_day = null;
$temp_s = $value;
$temp_day = $key;
$res_day .= $temp_day;
}
}
but the output is this:
FMThWT 09:00 - 18:00 May be I did something wrong but I dont know how to fix error. thanks