我想显示一个名单列表并用逗号分隔,姓氏应该以"和"分隔。用php。我需要帮助。
这是我的代码:
<?php
$bdaypersoname="";
do {
$bdaypersoname .= $row_Recordset2['Name']." , ";
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
$bdaypersoname= rtrim($bdaypersoname, " , ");
echo $bdaypersoname;
?>
</p>
答案 0 :(得分:0)
尝试这样,使用一些演示名称
$array = ['Alex','Bob','Collins','Danny'];
echo join(' and ', array_filter(array_merge(array(join(', ', array_slice($array, 0, -1))), array_slice($array, -1)), 'strlen'));