您的评论如下:
此代码显示成员选择,但仅显示为逗号分隔的列表:<?php bp_member_profile_data( \'field=Countries\' ); ?>
// $countries_csl should contain something like \'hufflepuff, hogwarts, heaven, hell\'
$contries_csl = bp_get_member_profile_data( \'field=Countries\' );
// convert the comma seperated list (csl) into an array by using explode( [delimiter], [string] )
$countries = explode( \',\', $countries_csl );
// check if the string to array conversion was successfull
if ( is_array( $countries ) && ! empty( $countries ) ) {
// adjust the html to your needs (add some css classes or something else)
echo \'<ul>\';
// walk over the array and print out a li-item for each array element
foreach ( $countries as $country ) {
// to be sure that every country starts with an UpperCase letter, use ucfirst()
printf( \'<li>%s</li>\', ucfirst( $country ) );
}
// do not forget to close the list
echo \'</ul>\';
}
你有一个逗号分隔的列表,你需要一个项目符号列表。只需将逗号分隔的列表转换为一个数组,并遍历它以生成项目符号列表。