echo '<ul>';echo '<li>' . implode( '</li><li>', $people) . '</li>';echo '</ul>';请注意,这将为空列表打印一个空的<li>-您可以添加一个签入以确保在生成任何输出之前该数组不为空(您需要进行任何循环,因此您不进行打印)一个空的<ul></ul>).Note this would print an empty <li> for an empty list - You can add a check in to make sure the array isn't empty before producing any output (which you would need for any loop so you don't print an empty <ul></ul>).if( count( $people) > 0) { echo '<ul>'; echo '<li>' . implode( '</li><li>', $people) . '</li>'; echo '</ul>';} 这篇关于将PHP数组输出到无序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 06:13