我有以下 if 语句,这些语句收集了在显示之前选择的所有日期。
$daysUsed = "";
if($this->dayweeksunsession==1){
$daysUsed .= "Su ";
}
if($this->dayweekmonsession==1){
$daysUsed .= "M ";
}
if($this->dayweektuessession==1){
$daysUsed .= "T ";
}
if($this->dayweekwedsession==1){
$daysUsed .= "W ";
}
if($this->dayweekthurssession==1){
$daysUsed .= "Th ";
}
if($this->dayweekfrisession==1){
$daysUsed .= "F ";
}
if($this->dayweeksatsession==1){
$daysUsed .= "Sa ";
}
if($daysUsed !=="") {
echo "</span><br/>Days of the Week: <span class='BoxReviewOutput'>";
echo $daysUsed;
}
我的问题是如何做到这一点,以便为会话中选择的一周中的每一天显示逗号,除了最后一天。
例如:选择了周日和周二。所以会显示“Su, T”
提前致谢!