我将如何将 PHP 数组添加到变量中,以便我可以将其作为一个变量添加到数据库中,例如
$personnel = ['name1', 'name2', 'name3'];
我尝试使用foreach然后将其添加到数据库中,但最后一个值仅发送到数据库
foreach ($personnel as $person) {
$p = $person.", ";
}
$sql = mysqli_query($con, "INSERT INTO travel_print (personnel, name, office, division, unit_head, position, date, purpose, venue, reference, date_to, date_from, activity, check_type) VALUES ('$p','$name','$office','$division','$unit_head','$position','$date','$purpose','$venue','$reference','$date_to','$date_from','$activity','$business')");
结果:

我需要的结果。

PIPIONE
肥皂起泡泡
烙印99
随时随地看视频慕课网APP