【发布时间】:2018-07-11 01:14:02
【问题描述】:
我正在使用这个功能:
// Get terms for post
$terms = get_the_terms($post->ID, 'skills');
if($terms != null) {
foreach($terms as $term) {
echo $term->name . ", ";
unset($term);
}
}
但是我将术语视为术语 1、术语 2、术语 3(末尾还有一个逗号),我如何在不需要时用逗号显示术语但不使用逗号?
【问题讨论】:
-
测试数组的结尾。如果你不是在最后,使用逗号,否则,跳过它。这是一个应该有帮助的例子。 stackoverflow.com/questions/6092054/…