使用下面的代码,最后一项 ($term->name) 返回最后一项的重复条目。
输出:
示例:计算机、时尚、出版、医学、医学
示例:IT、音乐、技术、技术
帮助!
<?php $vocabularies = taxonomy_get_vocabularies();
foreach($vocabularies as $vocabulary) {
if ($vocabularies) {
$terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary->vid);
if ($terms) {
$i = 1;
$len = count($terms);
foreach ($terms as $term) {
if ($i == 1) {
print '<span class="separator">' . t($term->name) . '</span>' . ' , '; }
else {
print '<span class="separator">' . t($term->name) . '</span>' . ' , '; }
if ($i == $len) {
print '<span class="separator">' . t($term->name) . '</span>'; }
$i++;
}
}
}
} ?>