每天也一样。我的意思是,OP特别提到我对PHP真的很陌生,后来我不知道如何使用print\r\u dump?请明确告诉我如何以及在哪里,这对我来说越简单越好。仅此而已。Re:“添加为键和值以使其独特”-由于我是编程新手,请您解释一下这对非专业人士意味着什么
每天也一样。我的意思是,OP特别提到我对PHP真的很陌生,后来我不知道如何使用print\r\u dump?请明确告诉我如何以及在哪里,这对我来说越简单越好。仅此而已。Re:“添加为键和值以使其独特”-由于我是编程新手,请您解释一下这对非专业人士意味着什么,php,comma,implode,Php,Comma,Implode,每天也一样。我的意思是,OP特别提到我对PHP真的很陌生,后来我不知道如何使用print\r\u dump?请明确告诉我如何以及在哪里,这对我来说越简单越好。仅此而已。Re:“添加为键和值以使其独特”-由于我是编程新手,请您解释一下这对非专业人士意味着什么?谢谢。在PHP中,数组键是唯一的,因此如果你最后得到了重复的名称(我不知道这是否可能),你将只得到一个。例如,假设你有一个术语$term->name='foo',这将变成['foo'=>”,所以你不能有两个数组键同时命名为foo。使用有意义的
每天也一样。我的意思是,OP特别提到
我对PHP真的很陌生,后来我不知道如何使用print\r\u dump?请明确告诉我如何以及在哪里
,这对我来说越简单越好。仅此而已。Re:“添加为键和值以使其独特”
-由于我是编程新手,请您解释一下这对非专业人士意味着什么?谢谢。在PHP中,数组键是唯一的,因此如果你最后得到了重复的名称(我不知道这是否可能),你将只得到一个。例如,假设你有一个术语$term->name='foo'
,这将变成['foo'=>”
,所以你不能有两个数组键同时命名为foo
。使用有意义的东西作为数组键只是一种习惯。希望这更有意义。。我用钥匙来证明这个事实。很多,我的意思是很多。Re:“添加为键和值以使其独特”
-由于我是编程新手,请您解释一下这对非专业人士意味着什么?谢谢。在PHP中,数组键是唯一的,因此如果你最后得到了重复的名称(我不知道这是否可能),你将只得到一个。例如,假设你有一个术语$term->name='foo'
,这将变成['foo'=>”
,所以你不能有两个数组键同时命名为foo
。使用有意义的东西作为数组键只是一种习惯。希望这更有意义。。我用钥匙来证明这个事实。很多,我是说很多。
$terms = get_the_terms( get_the_ID(), 'content' ); // “content” is your custom taxonomy name
if ( $terms && ! is_wp_error( $terms ) ) :
foreach ( $terms as $term ) {
echo '<div class="svg-icon-container" title="'.$term->description.'">'.$term->name.'</div>';
}
endif;
$terms_out = [];
$terms = get_the_terms( get_the_ID(), 'content' ); // “content” is your custom taxonomy name
if ( $terms && ! is_wp_error( $terms ) ) :
foreach ( $terms as $term ) {
$terms_out[] = '<div class="svg-icon-container" title="'.$term->description.'">'.$term->name.'</div>';
}
endif;
echo implode(', ', $terms_out);
<?php
ob_start();
$terms = get_the_terms( get_the_ID(), 'content' ); // “content” is your custom taxonomy name
if ( $terms && ! is_wp_error( $terms ) ) :
foreach ( $terms as $term ) {
echo '<div class="svg-icon-container" title="'.$term->description.'">'.$term->name.'</div>, ';
}
endif;
echo rtrim(ob_end_clean(), ', ');
$terms = get_the_terms( get_the_ID(), 'content' ); // “content” is your custom taxonomy name
if ( $terms && ! is_wp_error( $terms ) ){
$list = [];
foreach ( $terms as $term ) {
$list[$term->name] = $term->name; //add as both key and value to make it unique
}
//echo some opening html
echo implode(', ', $list);
//echo some closing html
}
$terms = get_the_terms( get_the_ID(), 'content' ); // “content” is your custom taxonomy name
if ( $terms && ! is_wp_error( $terms ) ){
$list = [];
foreach ( $terms as $term ) {
$list[$term->name] = '<div class="svg-icon-container" title="'.$term->description.'">'.$term->name.'</div>';
}
echo '<div id="my_list" >'.implode(', ', $list).'</div>';
}
$terms = get_the_terms( get_the_ID(), 'content' ); // “content” is your custom taxonomy name
if ( $terms && ! is_wp_error( $terms ) ){
$t = (array)$terms; //cast the object $terms to an array.
$list = array_column('name', $list);
echo implode(', ', $list);
}
echo '<div class="svg-icon-container" >'.implode('</div>, <div class="svg-icon-container" >', $list).'</div>';
$before = '<div class="svg-icon-container" >';
$after = '</div>';
echo $before .implode($after.', '.$before, $list).$after;