在过去的 1 1/2 天里,我一直在尝试将 16 行 id 存储到一个字符串中,并用逗号分隔每个 id。我得到的数组来自 MySQL。我得到的错误是
implode() 函数:传递了无效参数
$str=array();
$string="";
while($row = mysql_fetch_row($result))
{
$user_id=$row;
$str=$user_id;
foreach($str as $p=>$v){
comma($v);
}
}
function comma($v){
$string= implode(",",$v); echo $string;
}
尝试这样的事情:
$ids = array();
while ($row = mysql_fetch_assoc($result))
{
$ids[] = $row["UserID"];
}
echo implode(", ", $ids);
Replace "UserID"
与表中 id 的列名。
因此:首先构建数组,然后将数组内爆为字符串。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)