好的,我有这个代码
<?php //getting values
$column1 = $params->get('param1','');
$column2 = $params->get('param2','');
$column3 = $params->get('param3','');
$column4 = $params->get('param4','');
$column5 = $params->get('param5','');
//setting array and filter the empty values
$getvalues = array($column1,$column2,$column3,$column4,$column5);
$values = array_filter($getvalues); ?>
然后我在 foreach 中使用这些值
<?php foreach ( $values as $key=>$value ) : ?>
<div><?php echo $value; ?></div>
<?php endforeach; ?>
它完成了这项工作,但在循环之后,它添加了最后一项的值。为什么?