这是用于运行foreach循环的代码,该循环将在页面上动态呈现*。问题出在代码的这一部分。请引导我走向正确的方向。
*是页面顶部的回显,它应该按照代码在td内回显。
这是我正在使用的当前代码。
if( in_array($date, $dateKeyStack) ){
$calendar .= "<td class='day' rel='$date'><div class='current-day'>$currentDay</div><div class='current-events'>
<div class=\"have-events\">"; ?>
<?php
foreach($array_count_values as $key => $value){
if( $key == $date ){
$events_show_boxes = "*";
echo $events_show_boxes;
}
}
?><?php "
</div>
</td>";
} else if($currentDayRel == $today_date ){
$calendar .= "<td class='day its-today' rel='$date'><div class='current-day'>$currentDay</div><div class='current-events'> </div></td>";
} else {
$calendar .= "<td class='day' rel='$date'><div class='current-day'>$currentDay</div><div class='current-events'> </div></td>";
}
答案 0 :(得分:1)
您回复星号,但将表格构建为变量。将星号存储在日历变量中。
$calendar .= "<td class='day' rel='$date'><div class='current-day'>$currentDay</div><div class='current-events'>
<div class=\"have-events\">"; ?>
<?php
foreach($array_count_values as $key => $value){
if( $key == $date ){
$events_show_boxes = "*";
echo $events_show_boxes;
}
}
?>
或者不要在其他地方回应并使用该变量......
答案 1 :(得分:1)
if( in_array($date, $dateKeyStack) ){
$calendar .= "<td class='day' rel='$date'><div class='current-day'>$currentDay</div><div class='current-events'>
<div class=\"have-events\">"; ?>
<?php
foreach($array_count_values as $key => $value){
if( $key == $date ){
$events_show_boxes = "*";
$calendar.=$events_show_boxes;
}
}
?><?php $calendar.="
</div>
</td>";
}
echo $calendar
将$ events_show_boxes构建到日历变量
中