- $net = array('userid'=>'186966','username'=>'wskl','password'=>'123456');
$sql = 'update tbname set ';
$cont= count($net)-1;
foreach( $net as $k => $v ){
if($cont == 0)
{
$sql .= "$k = '{$v}' ";
}else
{
$sql .= "$k = '{$v}', ";
}
$cont--;
}
$sql .= ' where condition';
echo $sql;
以上是拼接更新的sql 語句時,如何去掉最後一個 ',' .sql