我想为除最后一个用户名之外的每个用户名添加一个逗号。例如:User1、User2、User3 我该怎么做?这是我的代码:
$user_online_sql = $db->query("SELECT DISTINCT account_id FROM online WHERE account_id != '-1';");
$users = '';
while ($user_online_row = mysql_fetch_array($user_online_sql)) {
$users .= $user->name($user_online_row['account_id']) . ' ';
}
我尝试了 implode 函数,但它只输出了一个空白结果,这是带有 implode 函数的代码:
$user_online_sql = $db->query("SELECT DISTINCT account_id FROM online WHERE account_id != '-1';");
$users = '';
while ($user_online_row = mysql_fetch_array($user_online_sql)) {
$users .= implode(', ',$user->name($user_online_row['account_id'])) . ' ';
}