获得条件,让他们之间有空间

时间:2017-01-13 作者:Sdesign

I am trying to show a list of terms that a post is located in. Within the admin it is showing posts in more than one term such as Mixed, Office. My issue is that with the code that I am using it is putting the into my templet but is placing the right next to each other and now adding space between them so it would look like Mixedoffice The code I am using is below. Thank you for any help on this.

<?php $terms = get_the_terms($property[\'ID\'], \'property_sub_type\');

if(!empty($terms)){

    foreach($terms as $value){

        echo $value->name;

    }

}
?> 
1 个回复
最合适的回答,由SO网友:Tunji 整理而成

您可以使用空格或换行符连接回显调用。

Space:

<?php $terms = get_the_terms($property[\'ID\'], \'property_sub_type\');

if(!empty($terms)){

    foreach($terms as $value){

        echo $value->name . " ";

    }

}

?> 

Newline:

<?php $terms = get_the_terms($property[\'ID\'], \'property_sub_type\');

if(!empty($terms)){

    foreach($terms as $value){

        echo $value->name . "\\n";

    }

}

?>