我有这个:
<?php
$values = $cfs->get('promoter');
if (!empty($values)) {
echo $cfs->get_labels('promoter');
echo implode(', ', array_keys($values));
}
?>
<br />
打印出类似这样的内容:
PromoterPromoter1, Promoter2
当我喜欢这样的事情时:
Promoter: Promoter1, Promoter2
另外,我怎么能在php中包含<br />
,所以如果该字段为空白,也会排除换行符?
感谢。
答案 0 :(得分:2)
<?php
$values = $cfs->get('promoter');
if (!empty($values)) {
echo $cfs->get_labels('promoter').": ";
echo implode(', ', array_keys($values))."<br />";
}
?>
使用PHP的串联运算符 - 即句点。
答案 1 :(得分:1)
您只需将字符串": "
附加到结尾
echo $cfs->get_labels('promoter').": ";
答案 2 :(得分:0)
<?php
$values = $cfs->get('promoter');
if (!empty($values)) {
$word = "";
$word .= $cfs->get_labels('promoter');
$word .= ": ";
$word .= implode(', ', array_keys($values));
$word .= "<br />";
echo $word;
}
?>